summaryrefslogtreecommitdiff
path: root/pylint/test/functional/not_context_manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/test/functional/not_context_manager.py')
-rw-r--r--pylint/test/functional/not_context_manager.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/pylint/test/functional/not_context_manager.py b/pylint/test/functional/not_context_manager.py
index 00af36c..97f6e97 100644
--- a/pylint/test/functional/not_context_manager.py
+++ b/pylint/test/functional/not_context_manager.py
@@ -108,3 +108,28 @@ class FullContextManager(ManagerMixin):
return self
def __exit__(self, *args):
pass
+
+# Test a false positive with returning a generator
+# from a context manager.
+def generator():
+ yield 42
+
+@contextmanager
+def context_manager_returning_generator():
+ return generator()
+
+with context_manager_returning_generator():
+ pass
+
+FIRST = [context_manager_returning_generator()]
+with FIRST[0]:
+ pass
+
+def other_indirect_func():
+ return generator()
+
+def not_context_manager():
+ return other_indirect_func()
+
+with not_context_manager(): # [not-context-manager]
+ pass