terminator/tests/testborg.py
bryce 0f201ade0f tests: Make tests easier to run at a package level
Add a run_tests script.  Move tests subdir to top level.  Force
terminatorlib into path for tests.

As of this commit, all tests pass:

  ~/src/Terminator/terminator$ ./run_tests 
  tests/testborg.py

  tests/test_doctests.py

  tests/testsignalman.py
  0/14 tests failed
2015-06-22 15:39:42 -07:00

60 lines
1.1 KiB
Python
Executable File

#!/usr/bin/python
# Terminator by Chris Jones <cmsj@tenshu.net>
# GPL v2 only
"""testborg.py - We are the borg. Resistance is futile.
doctests for borg.py
>>> obj1 = TestBorg()
>>> obj2 = TestBorg()
>>> obj1.attribute
0
>>> obj2.attribute
0
>>> obj1.attribute = 12345
>>> obj1.attribute
12345
>>> obj2.attribute
12345
>>> obj2.attribute = 54321
>>> obj1.attribute
54321
>>> obj3 = TestBorg2()
>>> obj3.attribute
1
>>> obj4 = TestBorg2()
>>> obj3.attribute = 98765
>>> obj4.attribute
98765
>>>
"""
import os
import sys, os.path
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), "..")))
from terminatorlib.borg import Borg
class TestBorg(Borg):
attribute = None
def __init__(self):
Borg.__init__(self, self.__class__.__name__)
self.prepare_attributes()
def prepare_attributes(self):
if not self.attribute:
self.attribute = 0
class TestBorg2(Borg):
attribute = None
def __init__(self):
Borg.__init__(self, self.__class__.__name__)
self.prepare_attributes()
def prepare_attributes(self):
if not self.attribute:
self.attribute = 1