File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -723,7 +723,7 @@ def test_get_random_number(mocker):
723
723
assert "RuntimeError" not in result .stderr .str ()
724
724
725
725
726
- def test_abort_context_manager (mocker ):
726
+ def test_abort_patch_object_context_manager (mocker ):
727
727
class A (object ):
728
728
def doIt (self ):
729
729
return False
@@ -740,3 +740,16 @@ def doIt(self):
740
740
)
741
741
742
742
assert str (excinfo .value ) == expected_error_msg
743
+
744
+
745
+ def test_abort_patch_context_manager (mocker ):
746
+ with pytest .raises (ValueError ) as excinfo :
747
+ with mocker .patch ("some_package" ):
748
+ pass
749
+
750
+ expected_error_msg = (
751
+ "Using mocker in a with context is not supported. "
752
+ "https://github.com/pytest-dev/pytest-mock#note-about-usage-as-context-manager"
753
+ )
754
+
755
+ assert str (excinfo .value ) == expected_error_msg
You can’t perform that action at this time.
0 commit comments