0
votes
3answers
97 views

Isolating unit tests in python

As a 30-year software developer, mostly in OO languages, but a newbie at python, I'm looking to find what is best practise for isolating unit tests in python. Let's say I have the following, ...
0
votes
3answers
85 views

Is it possible to have setup and tear down methods run only for specific unittests?

I currently have a test class with a setUp method for creating a temp file and a tearDown method for deleting a temp file. However, only some of the the test_ methods in that class require this ...
15
votes
8answers
560 views

What are good unit tests to cover the use case of rolling a die?

I'm trying to get to grips with unit testing. Say we have a die which can has a default number of sides equal to 6 (but can be 4, 5 sided etc.): import random class Die(): def __init__(self, ...
3
votes
2answers
127 views

Writing a unit test for a platform dependent unit

I have a method to be tested which depends on the OS, what's the best approach for testing the method depending on the OS? Is it to test on every OS that I have I require? Is there a better approach ...
1
vote
3answers
192 views

How should I go about bringing this code under test?

I'm working on an open-source test framework. 90% of my codebase has good test coverage. My main problem area is the command-line entry point. This module began life as a very short script for ...
3
votes
1answer
318 views

How to keep unit tests independent?

I've read it at many places that unit tests should be independent. In my case I have a class that does data transformation. These steps must be done sequentially, otherwise they don't make sense. For ...
3
votes
2answers
219 views

Do I need to learn python first to understand the part 2 of the book Test Driven development?

It seems like Python is used as a coding language for part 2 of Kent Beck's book Test Driven Development. I have read the first part of that book and started appreciating the value of TDD . First part ...
6
votes
3answers
2k views

Behavior Driven Development and Unit Testing in Python

We might be interested in starting to incorporate a unit test suite to our project, which is coded in Python (and it uses Redis, PostgreSQL and some third-party libraries, if that bears into the ...
1
vote
1answer
435 views

scons and python unit tests best practices

I am using scons to build a large project containing a mix of C++ and Python. I would like scons to run Python unit tests either using nose or not. Currently, we have a long list of tests files and ...
1
vote
2answers
2k views

Is there a good example of Python code for unit testing an api? [closed]

Do you know any good example of Python unit testing code for testing an API? Thanks! Update: Found this very interesting question: ...
2
votes
2answers
450 views

How to populate a private container for unit test?

I have a class that defines a private (well, __container to be exact since it is python) container. I am using the information within said container as part of the logic of what the class does and ...
5
votes
2answers
306 views

Writing functional tests for a legacy project

I am trying to add a couple of tests to a legacy C project. The project basically consists of a command line tool that prints something to stdout every time an event happens. Now, since writing unit ...
4
votes
1answer
236 views

What is the typical Pythonic view on re-using python modules outside of their initial intent?

Short Question Does it fly in the face of the Pythonic view to reuse / repurpose python modules for projects out side of their intent? Background Over the past several months I have been working on ...
6
votes
3answers
404 views

Is having a switch to turn mocking on or off a code smell?

I have a method that looks like this: def foobar(mock=False, **kwargs): # ... snipped foobar actually makes several calls to Amazon S3 and returns a composed result. In order to make this ...