Esempio n. 1
0
        def test_tree(root_path):
            ns1_dir = os.path.join(root_path, "ns1")
            files = ('a', 'b', 'c')
            self.ensure_eq(set(os.listdir(ns1_dir)), set(files),
                           "wrong files in namespace ns1 from {}", root_path)
            self.file_paths = {f : os.path.join(ns1_dir, f) for f in files}

        test_tree(test_dir)
        test_tree(self.namespaces_dir)

    @test
    def properties(self):
        content = { 'a' : '1', 'b' : '20', 'c' : '300' }
        [self.ensure_eq(open(fname, 'r').readline().strip(), content[name],
                        "expected file {} content", name) \
             for name, fname in self.file_paths.items()]

if __name__ == '__main__':
    tests_path = os.path.dirname(sys.argv[0])
    if len(sys.argv) == 3:
        statefs_bin = sys.argv[1]
        default_loader = sys.argv[2]
    elif len(sys.argv) > 1:
        raise Exception("Unknown arguments: {}".format(args))
    else:
        statefs_bin = os.path.join(tests_path, '../src/statefs')
        default_loader = os.path.join(tests_path, '../src/libloader-default.so')

    default_main(StateFS)

Esempio n. 2
0
        self.ensure(False, "e {}", "s")
        return True


class OtherTests(Suite):
    def init_a(self):
        self.a = 1

    suite_setup = [init_a]

    def before_test(self):
        self.a = 13
        self.teardown.append(self.after_first_test)

    def after_first_test(self):
        self.a = 31

    @test(setup=before_test)
    def test1(self):
        '''Other first test info'''
        self.ensure_eq(self.a, 13, "initialized in setup")

    @test
    def test2(self):
        '''Other first test info'''
        self.ensure_eq(self.a, 31, "after first")


if __name__ == '__main__':
    default_main(Tests, OtherTests)
Esempio n. 3
0
            ns1_dir = os.path.join(root_path, "ns1")
            files = ('a', 'b', 'c')
            self.ensure_eq(set(os.listdir(ns1_dir)), set(files),
                           "wrong files in namespace ns1 from {}", root_path)
            self.file_paths = {f: os.path.join(ns1_dir, f) for f in files}

        test_tree(test_dir)
        test_tree(self.namespaces_dir)

    @test
    def properties(self):
        content = {'a': '1', 'b': '20', 'c': '300'}
        [self.ensure_eq(open(fname, 'r').readline().strip(), content[name],
                        "expected file {} content", name) \
             for name, fname in self.file_paths.items()]


if __name__ == '__main__':
    tests_path = os.path.dirname(sys.argv[0])
    if len(sys.argv) == 3:
        statefs_bin = sys.argv[1]
        default_loader = sys.argv[2]
    elif len(sys.argv) > 1:
        raise Exception("Unknown arguments: {}".format(args))
    else:
        statefs_bin = os.path.join(tests_path, '../src/statefs')
        default_loader = os.path.join(tests_path,
                                      '../src/libloader-default.so')

    default_main(StateFS)
Esempio n. 4
0
        '''Second test info'''
        self.ensure(False, "e {}", "s")
        return True

class OtherTests(Suite):

    def init_a(self):
        self.a = 1

    suite_setup = [init_a]
    def before_test(self):
        self.a = 13
        self.teardown.append(self.after_first_test)

    def after_first_test(self):
        self.a = 31

    @test(setup = before_test)
    def test1(self):
        '''Other first test info'''
        self.ensure_eq(self.a, 13, "initialized in setup")

    @test
    def test2(self):
        '''Other first test info'''
        self.ensure_eq(self.a, 31, "after first")


if __name__ == '__main__':
    default_main(Tests, OtherTests)