I have inherited a relatively large (~30.000 lines) Python-based project (running on a CAD system for architects) with some messy methods that I have to bugfix at first and go on with the development. These methods place, say, bricks (or stuff like that), into a wall. So most of the code does 3D calculations on coords, vectors, etc.
There are no unit tests for the project currently (and I'm a complete noob for unit testing, I'm a brick-and-mortar architect). Because of the complexity of the functions I have decided to support my work with unit testing, the question is that how can I do it most effectively. Examples I have seen before are much website-based, working mostly on text docs.
The incoming parameters are very complex and large objects, and I use only few of the stored data. Obviously I have to make templates out of it.
There are two possible ways:
- To save a real word data as a Python pickle and later use this as a template, and save it to disk.
- To set up objects dynamically. Note that used objects'
__init__()methods are mostly like this:
class FirstClass:
def __init__():
self.x = 0
self.y = 0
self.fc = self.FirstClass()
class SecondClass:
def __init__():
self.blabla = 0
and so on, there are no complicated calculations. Obviously I can put my custom data by overwriting the initialized instance variables like this:
objects.in_the_test_used_data = some_numbers
My question is which is the better method for templates, or whether there is a better approach for this et.
Thx