예제 #1
0
    def test_generateCSV(self):
        current_week = datetime.datetime.today().strftime("%W")
        current_year = datetime.datetime.today().strftime("%Y")

        generateCSV(self.db_connection, BASE_DIR + '/test/temp/test.csv', str(int(current_week) - 1), current_week)

        assert not absfile(BASE_DIR + '/test/temp/test.csv') == None
예제 #2
0
    def test_generateCSV(self):
        current_week = datetime.datetime.today().strftime("%W")
        current_year = datetime.datetime.today().strftime("%Y")

        generateCSV(self.db_connection, BASE_DIR + '/test/temp/test.csv',
                    str(int(current_week) - 1), current_week)

        assert not absfile(BASE_DIR + '/test/temp/test.csv') == None
예제 #3
0
    def test_address(self):
        from nose.util import absfile, src

        class TC(unittest.TestCase):
            def runTest(self):
                raise Exception("error")

        def dummy(i):
            pass

        def test():
            pass

        class Test:
            def test(self):
                pass

            def test_gen(self):
                def tryit(i):
                    pass

                for i in range(0, 2):
                    yield tryit, i

            def try_something(self, a, b):
                pass

        fl = src(absfile(__file__))
        case = nose.case.Test(TC())
        self.assertEqual(case.address(), (fl, __name__, 'TC.runTest'))

        case = nose.case.Test(nose.case.FunctionTestCase(test))
        self.assertEqual(case.address(), (fl, __name__, 'test'))

        case = nose.case.Test(
            nose.case.FunctionTestCase(dummy, arg=(1, ), descriptor=test))
        self.assertEqual(case.address(), (fl, __name__, 'test'))

        case = nose.case.Test(
            nose.case.MethodTestCase(unbound_method(Test, Test.test)))
        self.assertEqual(case.address(), (fl, __name__, 'Test.test'))

        case = nose.case.Test(
            nose.case.MethodTestCase(unbound_method(Test, Test.try_something),
                                     arg=(
                                         1,
                                         2,
                                     ),
                                     descriptor=unbound_method(
                                         Test, Test.test_gen)))
        self.assertEqual(case.address(), (fl, __name__, 'Test.test_gen'))

        case = nose.case.Test(
            nose.case.MethodTestCase(unbound_method(Test, Test.test_gen),
                                     test=dummy,
                                     arg=(1, )))
        self.assertEqual(case.address(), (fl, __name__, 'Test.test_gen'))
예제 #4
0
    def test_address(self):
        from nose.util import absfile, src
        class TC(unittest.TestCase):
            def runTest(self):
                raise Exception("error")

        def dummy(i):
            pass

        def test():
            pass

        class Test:
            def test(self):
                pass

            def test_gen(self):
                def tryit(i):
                    pass
                for i in range (0, 2):
                    yield tryit, i

            def try_something(self, a, b):
                pass

        fl = src(absfile(__file__))
        case = nose.case.Test(TC())
        self.assertEqual(case.address(), (fl, __name__, 'TC.runTest'))

        case = nose.case.Test(nose.case.FunctionTestCase(test))
        self.assertEqual(case.address(), (fl, __name__, 'test'))

        case = nose.case.Test(nose.case.FunctionTestCase(
            dummy, arg=(1,), descriptor=test))
        self.assertEqual(case.address(), (fl, __name__, 'test'))

        case = nose.case.Test(nose.case.MethodTestCase(
                                  unbound_method(Test, Test.test)))
        self.assertEqual(case.address(), (fl, __name__, 'Test.test'))

        case = nose.case.Test(
            nose.case.MethodTestCase(unbound_method(Test, Test.try_something),
                                     arg=(1,2,),
                                     descriptor=unbound_method(Test,
                                                               Test.test_gen)))
        self.assertEqual(case.address(),
                         (fl, __name__, 'Test.test_gen'))

        case = nose.case.Test(
            nose.case.MethodTestCase(unbound_method(Test, Test.test_gen),
                                     test=dummy, arg=(1,)))
        self.assertEqual(case.address(),
                         (fl, __name__, 'Test.test_gen'))
예제 #5
0
파일: selector.py 프로젝트: thraxil/gtreed
 def fileInTests(self, file):
     orig = file
     if not os.path.isabs(file):
         file = absfile(file, self.conf.working_dir)
         log.debug("abs file %s is %s", orig, file)
     if file is None:
         log.debug("File %s does not exist" % orig)
         if self.tests:
             return False
         return True
     log.debug('Check file in tests')
     def match(filename, modname, funcname, file=file):
         return self.filematch(filename, modname, funcname, file)
     return self.anytest(match)
예제 #6
0
파일: selector.py 프로젝트: thraxil/gtreed
    def filematch(self, filename, modname, funcname, file):
        log.debug("Filematch (%s, %s, %s, %s)",
                  filename, modname, funcname, file)
        if filename is None:
            if modname is None:
                return None
            # be liberal... could this file possibly be this module?
            # return None if the module name, converted to a file
            # path, matches any part of the full filename
            mpath = os.path.sep.join(modname.split('.'))
            log.debug("Is module path %s in file %s?", mpath, file)
            if mpath in file:
                return None
            else:
                return False                    
        if not os.path.isabs(filename):
            filename = absfile(filename, self.conf.working_dir)
            log.debug("Abs match file: %s", filename)
            
        # A file is a match if it is an exact match, or if
        # the filename to match against is a directory (or package init file)
        # and the file appears to be under that directory. Files that
        # don't exist can't match.
        if filename is None:
            return False
        
        if filename.endswith('__init__.py'):
            dirname = os.path.dirname(filename)
        elif os.path.isdir(filename):
            dirname = filename
        else:
            dirname = None

        log.debug("Files are same: %s", filename == file)
        log.debug("Dirname: %s", dirname)
        if dirname is not None:
            log.debug("File startswith dirname: %s", file.startswith(dirname))
            try:
                log.debug("File has sep at end of dirname: %s == %s",
                          file[len(dirname)], os.path.sep)
            except IndexError:
                log.debug("File is not within dir")
        
        return filename == file \
               or (dirname is not None
                   and file.startswith(dirname)
                   and file[len(dirname)] == os.path.sep)