In this case, test_foo will have an additional argument, just like when decorating a method. If your method is also fixed, it will also add these arguments:
@patch.object(os, 'listdir') class TestPackage(unittest.TestCase): @patch.object(sys, 'exit') def test_foo(self, sys_exit, os_listdir): os_listdir.return_value = ['file1', 'file2'] # ... Test logic sys_exit.assert_called_with(1)
The order of the arguments is determined by the order of the calls to the decorators. The decorator method is created first, so it adds the first argument. The class decorator is external, so it will add a second argument. The same thing happens when you attach multiple patch decorators to the same test method or class (i.e., the external decorator comes last).
source share