class SomeUnitTests(TestCase):

    def test_something(self):


        class SomeMockObject(SomeActualObject):

            def foo(self2):
                self.assertEqual(self2.x, SOME_CONSTANT)
some_lib.do_something_with(SomeMockObject)
python variable scope