Unit testing with the nose: tests at compile time?

Is it possible for the nose block testing platform to run tests during the module compilation phase?

In fact, I would like to check something with the following structure:

x = 123
# [x is used here...]
def test_x():
  assert (x == 123)
del x  # Deleted because I don't want to clutter the module with unnecessary attributes

nosetests tells me that x is undefined, since it apparently runs test_x () after importing the module. Is there a way to conduct a nose test during the compilation phase, and after releasing the module from unnecessary resources after use?

+3
source share
2 answers

, . , "", ( ).

, , "__" ( , : wap- "private").

, , : , (.. ) ( ).

, , , , , , . , , , !

+2

TESTING :

if not TESTING:
    del x

, , .

, , - . , . , , , , , .

+2

Source: https://habr.com/ru/post/1708803/


All Articles