Fix Python – unittest Vs pytest

In unittest, I can setUp variables in a class and then the methods of this class can chose whichever variable it wants to use…
class test_class(unittest.TestCase):
def setUp(self):
self.varA = 1
self.varB = 2
self.varC = 3
self.modified_varA = 2

def test_1(self):

Fix Python – Using python’s mock patch.object to change the return value of a method called within another method

Is it possible to mock a return value of a function called within another function I am trying to test? I would like the mocked method (which will be called in many methods I’m testing) to returned my specified variables each time it is called. For example:
class Foo:
def method_1():
results = uses_some_other_method()
def method_n(….

Fix Python – Assert that a method was called in a Python unit test

Suppose I have the following code in a Python unit test:
aw = aps.Request(“nv1”)
aw2 = aps.Request(“nv2”, aw)

Is there an easy way to assert that a particular method (in my case aw.Clear()) was called during the second line of the test? e.g. is there something like this:
assertMethodIsCalled(aw.Clear, lambda: aps.Request(“nv2”, aw))

Fix Python – How to run Django’s test database only in memory?

My Django unit tests take a long time to run, so I’m looking for ways to speed that up. I’m considering installing an SSD, but I know that has its downsides too. Of course, there are things I could do with my code, but I’m looking for a structural fix. Even running a single test is slow since the database needs to be rebuilt / south migrated every….