All Questions
7 questions
8
votes
2
answers
7k
views
Mocking pathlib.Path I/O methods in a maintainable way which tests functionality not implementation
I have a function that constructs a path based on a function of inputs and creates the parent directory.
When writing a unit test for this function, I want to mock the I/O part of the function, ...
4
votes
2
answers
4k
views
Fake utcnow for the pytest
I want to create a pytest with a fake utcnow, but also I need to preserve the functionality of all other datetime methods. ...
3
votes
1
answer
1k
views
Python unittest.mock.patch.object context manager
I want to test my core of handler, so I wrote this:
...
3
votes
1
answer
2k
views
Using mocking to test that a Django view renders as expected
I have a Django view that ends with this...
return render(request, 'define/see_all.html', context)
I have mocked the render function and
...
6
votes
1
answer
3k
views
Testing file IO errors in python
Below is a simple class with two methods: the first calls open() to read in a file. The second calls the first method and does error handling.
There is also a ...
3
votes
2
answers
1k
views
Unit Testing of parser method using pytest
This is my first time using pytest. All feedback for this test case is much appreciated.
...
7
votes
1
answer
351
views
Monkeypatching __builtin__ in tests for mocking
I'm testing a little magic behaviour of my script that automatically reads from ~/.ghtoken to do automagic authentication on GitHub API requests. I want to test ...