예제 #1
0
class NamerTests(unittest.TestCase):
    def setUp(self):
        self.namer = StackFrameNamer()

    def test_class(self):
        self.assertEqual("NamerTests", self.namer.get_class_name())

    def test_method(self):
        n = StackFrameNamer()
        self.assertEqual("test_method", n.get_method_name())

    def test_file(self):
        self.assertTrue(os.path.exists(self.namer.get_directory() + "/test_namer.py"))

    def test_basename(self):
        n = StackFrameNamer()
        self.assertTrue(n.get_basename().endswith("NamerTests.test_basename"), n.get_basename())

    def test_received_name(self):
        filename = self.namer.get_received_filename('./stuff')
        self.assertEqual(filename, './stuff.received.txt')

    def test_approved_name(self):
        filename = self.namer.get_approved_filename('./stuff')
        self.assertEqual(filename, './stuff.approved.txt')

    def test_alternative_extension(self):
        n = Namer(extension='.html')
        filename = n.get_approved_filename('./stuff')
        self.assertEqual(filename, './stuff.approved.html')
예제 #2
0
 def setUp(self):
     self.namer = StackFrameNamer()
예제 #3
0
 def test_basename(self):
     n = StackFrameNamer()
     self.assertTrue(n.get_basename().endswith("NamerTests.test_basename"), n.get_basename())
예제 #4
0
def get_default_namer(extension=None):
    return StackFrameNamer(extension)
예제 #5
0
 def test_method(self):
     n = StackFrameNamer()
     self.assertEqual("test_method", n.get_method_name())
예제 #6
0
def get_default_namer(extension: Optional[str] = None) -> StackFrameNamer:
    return StackFrameNamer(extension)
예제 #7
0
 def test_class(self):
     self.assertEqual("NamerTests", StackFrameNamer().get_class_name())
예제 #8
0
 def test_approved_name(self):
     filename = StackFrameNamer().get_approved_filename("./stuff")
     self.assertEqual(filename, "./stuff.approved.txt")
예제 #9
0
 def test_file(self):
     directory = StackFrameNamer().get_directory()
     assert os.path.exists(directory + "/test_namer.py")
예제 #10
0
 def an_other_method(self):
     n = StackFrameNamer()
     self.assertEqual(
         "test_name_works_from_inside_an_other_method", n.get_method_name()
     )