5 new commits in pytest:

https://bitbucket.org/pytest-dev/pytest/commits/a80f7dc7a9e5/
Changeset:   a80f7dc7a9e5
Branch:      pytester-inline-run-clean-sys-modules
User:        schettino72
Date:        2015-04-21 02:16:04+00:00
Summary:     fix regendoc repository location on requirements-docs.txt.
Affected #:  1 file

diff -r eb60281e3952e5959005669a16c60a9979983de2 -r 
a80f7dc7a9e587b2e1804bf2fa96435472493a6b requirements-docs.txt
--- a/requirements-docs.txt
+++ b/requirements-docs.txt
@@ -1,2 +1,2 @@
 sphinx==1.2.3
-hg+ssh://h...@bitbucket.org/RonnyPfannschmidt/regendoc#egg=regendoc
+hg+ssh://h...@bitbucket.org/pytest-dev/regendoc#egg=regendoc


https://bitbucket.org/pytest-dev/pytest/commits/92c20dc049bd/
Changeset:   92c20dc049bd
Branch:      pytester-inline-run-clean-sys-modules
User:        schettino72
Date:        2015-04-21 02:18:04+00:00
Summary:     pytester: add method ``TmpTestdir.delete_loaded_modules()``
, and call it from ``inline_run()`` to allow temporary modules to be reloaded.
Affected #:  4 files

diff -r a80f7dc7a9e587b2e1804bf2fa96435472493a6b -r 
92c20dc049bd1a954ddb2a7669466baa46189962 AUTHORS
--- a/AUTHORS
+++ b/AUTHORS
@@ -48,3 +48,4 @@
 Tom Viner
 Dave Hunt
 Charles Cloud
+schettino72

diff -r a80f7dc7a9e587b2e1804bf2fa96435472493a6b -r 
92c20dc049bd1a954ddb2a7669466baa46189962 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
 2.8.0.dev (compared to 2.7.X)
 -----------------------------
 
+- pytester: add method ``TmpTestdir.delete_loaded_modules()``, and call it
+  from ``inline_run()`` to allow temporary modules to be reloaded.
 
 2.7.1.dev (compared to 2.7.0)
 -----------------------------

diff -r a80f7dc7a9e587b2e1804bf2fa96435472493a6b -r 
92c20dc049bd1a954ddb2a7669466baa46189962 _pytest/pytester.py
--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -266,7 +266,7 @@
 
         Some methods modify the global interpreter state and this
         tries to clean this up.  It does not remove the temporary
-        directlry however so it can be looked at after the test run
+        directory however so it can be looked at after the test run
         has finished.
 
         """
@@ -274,7 +274,15 @@
             sys.path.remove(p)
         if hasattr(self, '_olddir'):
             self._olddir.chdir()
-        # delete modules that have been loaded from tmpdir
+        self.delete_loaded_modules()
+
+    def delete_loaded_modules(self):
+        """Delete modules that have been loaded from tmpdir.
+
+        This allows the interpreter to catch module changes in case
+        the module is re-imported.
+
+        """
         for name, mod in list(sys.modules.items()):
             if mod:
                 fn = getattr(mod, '__file__', None)
@@ -539,6 +547,7 @@
         assert len(rec) == 1
         reprec = rec[0]
         reprec.ret = ret
+        self.delete_loaded_modules()
         return reprec
 
     def parseconfig(self, *args):

diff -r a80f7dc7a9e587b2e1804bf2fa96435472493a6b -r 
92c20dc049bd1a954ddb2a7669466baa46189962 testing/test_pytester.py
--- a/testing/test_pytester.py
+++ b/testing/test_pytester.py
@@ -2,6 +2,8 @@
 import os
 from _pytest.pytester import HookRecorder
 from _pytest.core import PluginManager
+from _pytest.main import EXIT_OK, EXIT_TESTSFAILED
+
 
 def test_make_hook_recorder(testdir):
     item = testdir.getitem("def test_func(): pass")
@@ -121,3 +123,12 @@
     testdir.inprocess_run([], [plugin])
 
     assert plugin.configured
+
+def test_inline_run_clean_modules(testdir):
+    test_mod = testdir.makepyfile("def test_foo(): assert True")
+    result = testdir.inline_run(str(test_mod))
+    assert result.ret == EXIT_OK
+    # rewrite module, now test should fail if module was re-imported
+    test_mod.write("def test_foo(): assert False")
+    result2 = testdir.inline_run(str(test_mod))
+    assert result2.ret == EXIT_TESTSFAILED


https://bitbucket.org/pytest-dev/pytest/commits/2361a9322d2f/
Changeset:   2361a9322d2f
User:        flub
Date:        2015-04-21 10:00:32+00:00
Summary:     Merge cleaning of sys.modules after pytester.inline_run()

Merged in schettino72/pytest/pytester-inline-run-clean-sys-modules
(pull request #278).
Affected #:  5 files

diff -r 0f7f18eb7bb74ffeebf9bb9dad87cf26bd7cb8ab -r 
2361a9322d2fd01a0addeab80fc1bd9a15e60a08 AUTHORS
--- a/AUTHORS
+++ b/AUTHORS
@@ -48,3 +48,4 @@
 Tom Viner
 Dave Hunt
 Charles Cloud
+Eduardo Schettino

diff -r 0f7f18eb7bb74ffeebf9bb9dad87cf26bd7cb8ab -r 
2361a9322d2fd01a0addeab80fc1bd9a15e60a08 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,9 @@
   of pkg_under_test whereas before they would always pick 
   up the local version.  Thanks Holger Krekel.
 
+- pytester: add method ``TmpTestdir.delete_loaded_modules()``, and call it
+  from ``inline_run()`` to allow temporary modules to be reloaded.
+  Thanks Eduardo Schettino.
 
 2.7.1.dev (compared to 2.7.0)
 -----------------------------

diff -r 0f7f18eb7bb74ffeebf9bb9dad87cf26bd7cb8ab -r 
2361a9322d2fd01a0addeab80fc1bd9a15e60a08 _pytest/pytester.py
--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -266,14 +266,22 @@
 
         Some methods modify the global interpreter state and this
         tries to clean this up.  It does not remove the temporary
-        directlry however so it can be looked at after the test run
+        directory however so it can be looked at after the test run
         has finished.
 
         """
         sys.path[:] = self._savesyspath
         if hasattr(self, '_olddir'):
             self._olddir.chdir()
-        # delete modules that have been loaded from tmpdir
+        self.delete_loaded_modules()
+
+    def delete_loaded_modules(self):
+        """Delete modules that have been loaded from tmpdir.
+
+        This allows the interpreter to catch module changes in case
+        the module is re-imported.
+
+        """
         for name, mod in list(sys.modules.items()):
             if mod:
                 fn = getattr(mod, '__file__', None)
@@ -537,6 +545,7 @@
         assert len(rec) == 1
         reprec = rec[0]
         reprec.ret = ret
+        self.delete_loaded_modules()
         return reprec
 
     def parseconfig(self, *args):

diff -r 0f7f18eb7bb74ffeebf9bb9dad87cf26bd7cb8ab -r 
2361a9322d2fd01a0addeab80fc1bd9a15e60a08 requirements-docs.txt
--- a/requirements-docs.txt
+++ b/requirements-docs.txt
@@ -1,2 +1,2 @@
 sphinx==1.2.3
-hg+ssh://h...@bitbucket.org/RonnyPfannschmidt/regendoc#egg=regendoc
+hg+ssh://h...@bitbucket.org/pytest-dev/regendoc#egg=regendoc

diff -r 0f7f18eb7bb74ffeebf9bb9dad87cf26bd7cb8ab -r 
2361a9322d2fd01a0addeab80fc1bd9a15e60a08 testing/test_pytester.py
--- a/testing/test_pytester.py
+++ b/testing/test_pytester.py
@@ -2,6 +2,8 @@
 import os
 from _pytest.pytester import HookRecorder
 from _pytest.core import PluginManager
+from _pytest.main import EXIT_OK, EXIT_TESTSFAILED
+
 
 def test_make_hook_recorder(testdir):
     item = testdir.getitem("def test_func(): pass")
@@ -121,3 +123,12 @@
     testdir.inprocess_run([], [plugin])
 
     assert plugin.configured
+
+def test_inline_run_clean_modules(testdir):
+    test_mod = testdir.makepyfile("def test_foo(): assert True")
+    result = testdir.inline_run(str(test_mod))
+    assert result.ret == EXIT_OK
+    # rewrite module, now test should fail if module was re-imported
+    test_mod.write("def test_foo(): assert False")
+    result2 = testdir.inline_run(str(test_mod))
+    assert result2.ret == EXIT_TESTSFAILED


https://bitbucket.org/pytest-dev/pytest/commits/8186dfdc5250/
Changeset:   8186dfdc5250
Branch:      pytester-inline-run-clean-sys-modules
User:        flub
Date:        2015-04-21 10:01:03+00:00
Summary:     Close merged feature branch
Affected #:  0 files



https://bitbucket.org/pytest-dev/pytest/commits/8ab27356e61e/
Changeset:   8ab27356e61e
Branch:      prefer_installed
User:        flub
Date:        2015-04-21 10:01:21+00:00
Summary:     Close merged feature branch
Affected #:  0 files

Repository URL: https://bitbucket.org/pytest-dev/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
pytest-commit mailing list
pytest-commit@python.org
https://mail.python.org/mailman/listinfo/pytest-commit

Reply via email to