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

Use pytest instead of testtools #35

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ralittles
Copy link

Ported all of the unit tests written in testtools from the tests/ directory to now be based on the pytest package and live in the pytests/ directory.

Unfortunately Pytest compatiability is limited to Python 3. To run them, do:

$ python3 -m pytest pytests/

From the regular root directory of the project.

You should see:

=========================================================== test session starts ============================================================
platform linux -- Python 3.5.2, pytest-4.0.2, py-1.7.0, pluggy-0.8.0
rootdir: /home/dev/version1/Version1fromGithub/VersionOne.SDK.Python, inifile:
collected 25 items                                                                                                                         

pytests/test_common_setup.py .                                                                                                       [  4%]
pytests/test_connects.py .........                                                                                                   [ 40%]
pytests/test_creations.py ...                                                                                                        [ 52%]
pytests/test_operations.py ..                                                                                                        [ 60%]
pytests/test_queries.py .........                                                                                                    [ 96%]
pytests/test_string_utils.py .                                                                                                       [100%]

======================================================== 25 passed in 78.69 seconds ========================================================

The original tests/ directory was left in for Python 2 compatbility and are still accessible and passing via the target in setup.py.

Here are the results:



running egg_info
writing requirements to v1pysdk.egg-info/requires.txt
writing v1pysdk.egg-info/PKG-INFO
writing top-level names to v1pysdk.egg-info/top_level.txt
writing dependency_links to v1pysdk.egg-info/dependency_links.txt
reading manifest file 'v1pysdk.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'product.json'
writing manifest file 'v1pysdk.egg-info/SOURCES.txt'
running build_ext
test_create_story (tests.creation_tests.TestV1Create)
tests.creation_tests.TestV1Create.test_create_story ... ok
test_connect (tests.connect_tests.TestV1Connection)
tests.connect_tests.TestV1Connection.test_connect ... ok
test_connect_fails_when_invalid (tests.connect_tests.TestV1Connection)
tests.connect_tests.TestV1Connection.test_connect_fails_when_invalid ... ok
test_meta_connect_instance_and_address (tests.connect_tests.TestV1Connection)
tests.connect_tests.TestV1Connection.test_meta_connect_instance_and_address ... ok
test_meta_connect_instance_url (tests.connect_tests.TestV1Connection)
tests.connect_tests.TestV1Connection.test_meta_connect_instance_url ... ok
test_meta_connect_instance_url_overrides_separate (tests.connect_tests.TestV1Connection)
tests.connect_tests.TestV1Connection.test_meta_connect_instance_url_overrides_separate ... ok
test_meta_connect_oauth (tests.connect_tests.TestV1Connection)
tests.connect_tests.TestV1Connection.test_meta_connect_oauth ... ok
test_meta_connect_oauth_ignores_username (tests.connect_tests.TestV1Connection)
tests.connect_tests.TestV1Connection.test_meta_connect_oauth_ignores_username ... ok
test_reconnect_fails_when_invalid (tests.connect_tests.TestV1Connection)
tests.connect_tests.TestV1Connection.test_reconnect_fails_when_invalid ... ok
test_reconnect_succeeds_after_invalid (tests.connect_tests.TestV1Connection)
tests.connect_tests.TestV1Connection.test_reconnect_succeeds_after_invalid ... ok
test_find_query (tests.query_tests.TestV1Query)
tests.query_tests.TestV1Query.test_find_query ... ok
test_non_default_query (tests.query_tests.TestV1Query)
tests.query_tests.TestV1Query.test_non_default_query ... ok
test_select_epic (tests.query_tests.TestV1Query)
tests.query_tests.TestV1Query.test_select_epic ... ok
test_select_scope (tests.query_tests.TestV1Query)
tests.query_tests.TestV1Query.test_select_scope ... ok
test_select_story (tests.query_tests.TestV1Query)
tests.query_tests.TestV1Query.test_select_story ... ok
test_select_story_as_generic_asset (tests.query_tests.TestV1Query)
tests.query_tests.TestV1Query.test_select_story_as_generic_asset ... ok
test_select_task (tests.query_tests.TestV1Query)
tests.query_tests.TestV1Query.test_select_task ... ok
test_sum_query (tests.query_tests.TestV1Query)
tests.query_tests.TestV1Query.test_sum_query ... ok
test_split_attribute (tests.string_utils_tests.TestStringUtils)
tests.string_utils_tests.TestStringUtils.test_split_attribute ... ok
test_quick_close_and_reopen (tests.operation_tests.TestV1Operations)
tests.operation_tests.TestV1Operations.test_quick_close_and_reopen ... ok

----------------------------------------------------------------------
Ran 20 tests in 61.958s

OK

@mtalexan
Copy link
Owner

@ralittles What's the benefit of using pytest vs testtools? It doesn't integrate with the setup.py (or at least you didn't integrate it), and it only works for Python3.

@mtalexan mtalexan added enhancement New feature or request internal-tools Pull request targets internal tooling like self-tests, build, etc labels Dec 20, 2019
@mtalexan mtalexan changed the title Use pytest instead of testtools Use pytest in addition to testtools Dec 20, 2019
@mtalexan
Copy link
Owner

@ralittles I think if the project is going to drop support for python2 and switch over to python3 only, this could be accepted. However you would need to update the setuptools to use pytest instead of testtools for the test target, and drop the old testtools code.
Make it work with the setup.py file as the only test tool, and I'll mark the pull request for when Python2 support is dropped

@mtalexan mtalexan added the python3-only Change/feature can only be supported after Python2 support is dropped label Dec 20, 2019
@mtalexan mtalexan changed the title Use pytest in addition to testtools Use pytest instead of testtools Dec 20, 2019
s31db pushed a commit to s31db/VersionOne.SDK.Python that referenced this pull request Mar 3, 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 internal-tools Pull request targets internal tooling like self-tests, build, etc python3-only Change/feature can only be supported after Python2 support is dropped
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants