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

Modules, functions and classes crashing or hanging to be added to the blacklist. #12

Open
alexamici opened this issue Feb 5, 2016 · 4 comments
Assignees
Milestone

Comments

@alexamici
Copy link
Collaborator

alexamici commented Feb 5, 2016

pytest-nodev have a module blacklist and an object blacklist that is update with every release.

If the enabling pytest-nodev crashes of hangs the pytest process you have probably found a problem object that needs to be added to the blacklist. In order to identify the problem object remove all non essential options from the command line, in particular --candidates-fail and -n, and add -vv instead. Any test line that doesn't end with xfail is a good candidate, especially if it is the last line before the summary or the crash report. For example the following command hangs:

$ py.test -vv examples/test_rfc3986_parse.py --candidates-from-modules itertools
[...]
examples/test_rfc3986_parse.py::test_rfc3986_parse_basic[itertools:count] xfail
examples/test_rfc3986_parse.py::test_rfc3986_parse_full[itertools:count] xfail
examples/test_rfc3986_parse.py::test_rfc3986_parse_basic[itertools:cycle]

and this is a hint that itertools:cycle causes the hang.

Comment here to submit objects that crash or hang during the candidate fixture for review, be sure to mention the the full object name, usually the string in square brackets.

@alexamici alexamici self-assigned this Feb 5, 2016
@alexamici alexamici added this to the 0.9.0 milestone Feb 5, 2016
@francesconazzaro
Copy link
Contributor

the following modules and functions hang pytest process:

  • Tix
  • compiler.ast:AugAssign
  • commands
  • compiler
  • cookielib
  • os.command
  • subprocess
  • platform:popen
  • plistlib:readPlistFromResource
  • posix:popen
  • pydoc:apropos
  • signal
  • ttk:Scale
  • ttk:Menubutton

@alexamici alexamici modified the milestones: 1.0.0, 0.9.0 Feb 5, 2016
@kr1
Copy link

kr1 commented Feb 12, 2016

pycallgraph crashes pytest-wish because it monkeypatches inspect.getmodule at import.
This is therefore a general case (albeit probably infrequent). A simple workaround would be a contextmanager around those calls, along the lines of:

+@contextmanager
+def reset_function(function):
+    original_function = function
+    yield
+    function = original_function

@@ -104,13 +110,15 @@ def import_distributions(distribution_modules,           
module_blacklist_pattern=MODULE_B

def generate_module_objects(module, predicate=None):
    try:
-        module_members = inspect.getmembers(module, predicate)
+        with reset_function(getmembers):
+            module_members = getmembers(module, predicate)

@alexamici
Copy link
Collaborator Author

@ kr1 I don't think we can really protect from modules that fiddle with the infrastructure that we use, mainly module load and introspection, as we would need to save and restore also all nested functions. The only safe strategies are:

  • use as little infrastructure as possible
  • blacklist modules that temper the infrastructure we need

Good catch! I added it to the blacklist for now.

@alexamici
Copy link
Collaborator Author

Blacklisted many stdlib objects with broken __del__ methods that pollute output with Exception ignored in: noise.

Move issue to next release.

@alexamici alexamici modified the milestones: 1.1.0, 1.0.0 Jul 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants