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

Support pytest7 #167

Open
musicinmybrain opened this issue Apr 15, 2023 · 4 comments
Open

Support pytest7 #167

musicinmybrain opened this issue Apr 15, 2023 · 4 comments

Comments

@musicinmybrain
Copy link
Contributor

The current version 0.9.0 does not work with the current version of pytest (7.3.1), which is a problem in cases such as Linux distributions where only the latest version of pytest is available.

Prior to 0.9.0, the patch described in #116 (comment) was viable, but it seems like things may have diverged too much since then.

Working on the current master, b9f6a64, without any patches, I tried enabling the tests in tox.ini as follows:

diff --git a/tox.ini b/tox.ini
index f109b95..9682e27 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
 [tox]
 # NOTE: when adding Python versions, also update and re-run `./rebuild-circleci-yaml`
-envlist=pypy3-{nose,nose2,pytest3,unit,unit2},py{37,38,39}-{nose,nose2,pytest3,unit,unit2},py{310,311}-{unit,nose2}
+envlist=pypy3-{nose,nose2,pytest3,pytest7,unit,unit2},py{37,38,39}-{nose,nose2,pytest3,pytest7,unit,unit2},py{310,311}-{unit,nose2}
 
 [testenv]
 deps=
@@ -10,6 +10,7 @@ deps=
     pytest2: pytest>=2,<3
     pytest3: pytest>=3,<4
     #pytest4: pytest>=4,<5
+    pytest7: pytest>=7,<8
     unit2: unittest2
 commands=
     nose: nosetests
@@ -17,5 +18,6 @@ commands=
     pytest2: py.test parameterized/test.py
     pytest3: py.test parameterized/test.py
     #pytest4: py.test parameterized/test.py
+    pytest7: py.test parameterized/test.py
     unit: python -m unittest parameterized.test
-    unit2: unit2 parameterized.test
\ No newline at end of file
+    unit2: unit2 parameterized.test

When I run one of the resulting environments I get an error, e.g.:

$ python -m tox -e py311-pytest7
...
collected 73 items                                                             

parameterized/test.py xx......x........xx..x.......................x.s.. [ 68%]
xxxx...................E                                                 [100%]

==================================== ERRORS ====================================
_ ERROR at teardown of TestAsyncParameterizedExpandWithNoMockPatchForClass.test_one_async_function_patch_decorator_2_foo1 _

    def tearDownModule():
        missing = sorted(list(missing_tests))
>       assert_equal(missing, [])
E       AssertionError: Lists differ: ["test_instance_method('foo0', bar=None)",[683 chars]o')"] != []
E       
E       First list contains 17 additional elements.
E       First extra element 0:
E       "test_instance_method('foo0', bar=None)"
E       
E       Diff is 786 characters long. Set self.maxDiff to None to see it.

parameterized/test.py:489: AssertionError
...

Is there any chance of making this work in the relatively near future? Thanks!

@musicinmybrain
Copy link
Contributor Author

If I simply comment out the failing assertion in tearDownModule, the rest of the tests pass, and the packages that use parameterized in Fedora still build from source. I haven’t attempted to figure out why that assertion is failing, though.

@mcepl
Copy link

mcepl commented May 12, 2023

Actually, whole idea of assert in tearDown method seems a bit suspicious to me.

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this issue May 13, 2023
https://build.opensuse.org/request/show/1086781
by user mcepl + dimstar_suse
- Update to 0.9.0:
  - Drop support for Python 2.X, 3.5, and 3.6;
    Add support for Python 3.10, 3.11
  - Modernize from setup.py -> pyproject.toml
  - Add ``namespace`` argument to ``@parameterize.expand``
  - Add support for ``IsolatedAsyncioTestCase``
  - Work around for bug bpo-40126 in older versions of ``mock``
  - Allow str, bytes, and any non-iterable input to be passed to
    ``@parameterized`` without wrapping in a tuple
  - Fix class-level ``mock.patch.multiple``
- Add skip_failing_teardown.patch (gh#wolever/parameterized#167)
  to overcome failing tearDownModule().
- Remove upstreamed parameterized-pr116-pytest4.patch
@mtelka
Copy link

mtelka commented Nov 5, 2024

I assume the test_one_async_function_patch_decorator_2_foo1 test failure is because the missing_tests list is non-empty and this is because of the following warnings (please note that test_instance_method in missing_tests is also listed below):

parameterized/test.py:111
  parameterized/test.py:111: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_naked_function will be ignored
    @parameterized(test_params)

parameterized/test.py:285
  parameterized/test.py:285: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_mock_patch_standalone_function will be ignored
    @parameterized([(42, )])

parameterized/test.py:322
  parameterized/test.py:322: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_mock_patch_multiple_standalone will be ignored
    @parameterized([(42, )])

parameterized/test.py:474
  parameterized/test.py:474: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_wrapped_iterable_input will be ignored
    @parameterized(lambda: iter(["foo"]))

parameterized/test.py:519
  parameterized/test.py:519: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_parameterized_argument_value_pairs will be ignored
    @parameterized([

parameterized/test.py:542
  parameterized/test.py:542: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_short_repr will be ignored
    @parameterized([

parameterized/test.py:551
  parameterized/test.py:551: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_with_docstring will be ignored
    @parameterized([  

parameterized/test.py:561
  parameterized/test.py:561: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_cases_over_10 will be ignored
    @parameterized(cases_over_10)
  
parameterized/test.py:126
  parameterized/test.py:126: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_instance_method will be ignored
    @parameterized(test_params)

parameterized/test.py:205
  parameterized/test.py:205: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_patch_class_no_expand will be ignored
    @parameterized([(42, 51)])

parameterized/test.py:274
  parameterized/test.py:274: PytestCollectionWarning: yield tests were removed in pytest 4.0 - test_patch_no_expand will be ignored
    @parameterized([(42, 51)])

@mtelka
Copy link

mtelka commented Nov 5, 2024

BTW, I assume this is a duplicate of #122.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants