diff --git a/.bzrignore b/.bzrignore index 03eef862..5c359985 100644 --- a/.bzrignore +++ b/.bzrignore @@ -3,3 +3,4 @@ terminatorlib/*.pyc .project .pydevproject terminatorlib/meliae +_trial_temp diff --git a/terminatorlib/borg.py b/terminatorlib/borg.py index ec9d3770..d61e7283 100755 --- a/terminatorlib/borg.py +++ b/terminatorlib/borg.py @@ -6,30 +6,6 @@ ActiveState's policy appears to be that snippets exist to encourage re-use, but I can not find any specific licencing terms. - ->>> 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 ->>> - """ from util import dbg @@ -77,31 +53,3 @@ class Borg: """This should be used to prepare any attributes of the borg class.""" raise NotImplementedError('prepare_attributes') -if __name__ == '__main__': - 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 - - import sys - import doctest - (failed, attempted) = doctest.testmod() - print "%d/%d tests failed" % (failed, attempted) - sys.exit(failed) diff --git a/terminatorlib/testborg.py b/terminatorlib/testborg.py new file mode 100755 index 00000000..0dbc5df9 --- /dev/null +++ b/terminatorlib/testborg.py @@ -0,0 +1,55 @@ +#!/usr/bin/python +# Terminator by Chris Jones +# 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 +>>> + +""" + +from 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 + diff --git a/terminatorlib/tests/test_doctests.py b/terminatorlib/tests/test_doctests.py index 2b4c6d90..0fb46d30 100644 --- a/terminatorlib/tests/test_doctests.py +++ b/terminatorlib/tests/test_doctests.py @@ -7,7 +7,7 @@ def test_suite(): for name in ( 'config', 'plugin', - 'borg', + 'testborg', ): suite.addTest(DocTestSuite('terminatorlib.' + name)) return suite