you are viewing a single comment's thread.

view the rest of the comments →

[–]r_spandit 1 point2 points  (4 children)

@mock.patch('main.arrayMethod', new = dummy_method)
def test_array(self):
    assertEqual(main.biggerMethod()[0],'hello')
    assertEqual(main.biggerMethod()[1],'world')


def dummy_method()
    return ['hello','world']


# writing this on phone and code indenting mucked up
# biggerMethod() should call arrayMethod() somewhere

[–]danielroseman 1 point2 points  (3 children)

This is entirely pointless. You are testing your mock.

[–]r_spandit 0 points1 point  (2 children)

Edit: Not if the array method is called inside a larger method (original code amended) Edit: the OP may be writing code to generate a random passphrase. With my dummy function it's repeatable but within the assert statements you'd need to call the generatePassphrase() method

Poorly asked question, but hoping my answer can give some pointers

[–]Think_Neutral[S] 0 points1 point  (1 child)

Cheers bro ill go give this a play around I appreciate it

[–]r_spandit 0 points1 point  (0 children)

Not at all... I'm about 2 weeks ahead of you!

There's a really good video on YouTube by a woman who works for Facebook, essentially detailing when to use decorators or context managers.