pytest-dev / apipkg

MIT License
55 stars 16 forks source link

Pytest4 errors #14

Closed dimon222 closed 3 years ago

dimon222 commented 5 years ago

Related pages: Deprecation - https://docs.pytest.org/en/latest/changelog.html#pytest-3-9-0-2018-10-15-not-published-due-to-a-release-automation-bug And in 4.x it became error - https://docs.pytest.org/en/latest/changelog.html#pytest-4-0-0-2018-11-13

self = TempdirFactory(_tmppath_factory=TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0xf7074530>, _basetemp=None))
string = 'test_apipkg', dir = 1

    def ensuretemp(self, string, dir=1):
        """ (deprecated) return temporary directory path with
            the given string as the trailing part.  It is usually
            better to use the 'tmpdir' function argument which
            provides an empty unique-per-test-invocation directory
            and is guaranteed to be empty.
        """
        # py.log._apiwarn(">1.1", "use tmpdir function argument")
        from .deprecated import PYTEST_ENSURETEMP

>       warnings.warn(PYTEST_ENSURETEMP, stacklevel=2)
E       RemovedInPytest4Warning: pytest/tmpdir_factory.ensuretemp is deprecated, 
E       please use the tmp_path fixture or tmp_path_factory.mktemp

/usr/lib/python2.7/site-packages/_pytest/tmpdir.py:104: RemovedInPytest4Warning
____________ ERROR at setup of TestRealModule.test_realmodule_repr _____________

cls = <class test_apipkg.TestRealModule at 0xf7129e68>

    def setup_class(cls):
>       cls.tmpdir = py.test.ensuretemp('test_apipkg')

test_apipkg.py:16: 

And couple of warnings that would be good to fix too https://docs.pytest.org/en/latest/deprecations.html#raises-warns-exec

test_apipkg.py::test_error_loading_one_element
  /home/buildozer/aports/testing/py-apipkg/src/apipkg-1.5/test_apipkg.py:322: PytestDeprecationWarning: raises(..., 'code(as_a_string)') is deprecated, use the context manager form or use `exec()` directly
andypost commented 5 years ago

workaround

--- a/test_apipkg.py
+++ b/test_apipkg.py
@@ -13,7 +13,7 @@
 class TestRealModule:

     def setup_class(cls):
-        cls.tmpdir = py.test.ensuretemp('test_apipkg')
+        cls.tmpdir = py.path.local('test_apipkg')
         sys.path = [str(cls.tmpdir)] + sys.path
         pkgdir = cls.tmpdir.ensure('realtest', dir=1)
swt2c commented 5 years ago

@RonnyPfannschmidt any chance this could get fixed and a new release?

RonnyPfannschmidt commented 3 years ago

this has beenn fixed in #9