Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider using pytest instead of unittest #83

Open
MartinFlores751 opened this issue Sep 8, 2023 · 0 comments
Open

Consider using pytest instead of unittest #83

MartinFlores751 opened this issue Sep 8, 2023 · 0 comments
Labels
enhancement New feature or request testing
Milestone

Comments

@MartinFlores751
Copy link
Contributor

Think this might be of interest...

Pros:

  • pytest has pytest-xdist for parallel testing, (pytest-parallel supports parallel & concurrent, but it's not maintained...)
  • fancy test additions

Bonus:

  • plugins
  • tests don't have to be classes/part of a class
  • pytest can run existing unittest tests

Cons:

  • We have to install pytest & desired plugins, not baked in like unittest
  • fancy test additions (have to learn something new)
  • tests need to be written with parallelism in mind (if parallel tests wanted)

Mini example of 4 tests:

import pytest
import requests

@pytest.mark.parametrize("username, password, expected_result", [('rods','rods',200),
                                                                 ('','',401),
                                                                 ('not','valid',401),
                                                                 ('a'*200,'b'*200, 401)])
def test_post_basic_login(username, password, expected_result):
    auth_url = 'http://127.0.0.1:9000/irods-http-api/0.1.0/authenticate'

    res = requests.post(auth_url, auth=(username, password))

    # Got a good code, assume we passed...
    assert res.status_code == expected_result
@trel trel added the enhancement New feature or request label Sep 16, 2023
@korydraughn korydraughn added this to the 0.2.0 milestone Nov 1, 2023
@korydraughn korydraughn modified the milestones: 0.2.0, 0.3.0 Jan 11, 2024
@trel trel modified the milestones: 0.3.0, 0.4.0 Mar 15, 2024
@korydraughn korydraughn modified the milestones: 0.4.0, 0.5.0 Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing
Projects
None yet
Development

No branches or pull requests

3 participants