This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if __name__ == "__main__": | |
| args = ["", "recipe13", "--with-regexpicker", \ | |
| "--re-pattern=test.*|length", "--verbosity=2"] | |
| print "With verbosity..." | |
| print "====================" | |
| nose.run(argv=args, plugins=[RegexPicker()]) | |
| print "Without verbosity..." | |
| print "====================" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| err = sys.stderr | |
| import nose | |
| from nose.plugins import Plugin | |
| class RegexPicker(Plugin): | |
| name = "regexpicker" | |
| def __init__(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from recipe7 import * | |
| from recipe7_legacy import * | |
| import unittest | |
| if __name__ == "__main__": | |
| tester = RomanNumeralTester() | |
| suite = unittest.TestSuite() | |
| for test in [tester.simple_test, tester.combo_test1, \ | |
| tester.combo_test2, tester.other_test]: | |
| testcase = unittest.FunctionTestCase(test) | |
| suite.addTest(testcase) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from recipe7 import * | |
| class RomanNumeralTester(object): | |
| def __init__(self): | |
| self.cvt = RomanNumeralConverter() | |
| def simple_test(self): | |
| print "+++ Converting M to 1000" | |
| assert self.cvt.convert_to_decimal("M") == 1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RomanNumeralConverter(object): | |
| def __init__(self): | |
| self.digit_map = {"M":1000, "D":500, "C":100, "L":50, "X":10, "V":5, "I":1} | |
| def convert_to_decimal(self, roman_numeral): | |
| val = 0 | |
| for char in roman_numeral: | |
| val += self.digit_map[char] | |
| return val |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RomanNumeralConverter(object): | |
| def __init__(self): | |
| self.digit_map = {"M":1000, "D":500, "C":100, "L":50, "X":10, "V":5, "I":1} | |
| def convert_to_decimal(self, roman_numeral): | |
| val = 0 | |
| for char in roman_numeral: | |
| val += self.digit_map[char] | |
| return val |
NewerOlder