Exemple #1
0
 def configureWhere(self, where):
     """Configure the working directory or directories for the test run.
     """
     from nose.importer import add_path
     self.workingDir = None
     where = tolist(where)
     warned = False
     for path in where:
         if not self.workingDir:
             abs_path = absdir(path)
             if abs_path is None:
                 raise ValueError("Working directory %s not found, or "
                                  "not a directory" % path)
             log.info("Set working dir to %s", abs_path)
             self.workingDir = abs_path
             if self.addPaths and \
                    os.path.exists(os.path.join(abs_path, '__init__.py')):
                 log.info("Working directory %s is a package; "
                          "adding to sys.path" % abs_path)
                 add_path(abs_path)
             continue
         if not warned:
             warn("Use of multiple -w arguments is deprecated and "
                  "support may be removed in a future release. You can "
                  "get the same behavior by passing directories without "
                  "the -w argument on the command line, or by using the "
                  "--tests argument in a configuration file.",
                  DeprecationWarning)
         self.testNames.append(path)
Exemple #2
0
 def configureWhere(self, where):
     """Configure the working directory or directories for the test run.
     """
     from nose.importer import add_path
     self.workingDir = None
     where = tolist(where)
     warned = False
     for path in where:
         if not self.workingDir:
             abs_path = absdir(path)
             if abs_path is None:
                 raise ValueError("Working directory %s not found, or "
                                  "not a directory" % path)
             log.info("Set working dir to %s", abs_path)
             self.workingDir = abs_path
             if self.addPaths and \
                    os.path.exists(os.path.join(abs_path, '__init__.py')):
                 log.info("Working directory %s is a package; "
                          "adding to sys.path" % abs_path)
                 add_path(abs_path)
             continue
         if not warned:
             warn(
                 "Use of multiple -w arguments is deprecated and "
                 "support may be removed in a future release. You can "
                 "get the same behavior by passing directories without "
                 "the -w argument on the command line, or by using the "
                 "--tests argument in a configuration file.",
                 DeprecationWarning)
             warned = True
         self.testNames.append(path)
Exemple #3
0
def is_parent_path(path, parents, excludes = [ ]):
    """Returns True if path is a child folder of one of the paths in parents, but not excluded under excludes"""
    _path = absdir(os.path.expanduser(os.path.expandvars(path)))
    if not _path:
        return False

    if not _path.endswith(os.path.sep):
        _path = _path + os.path.sep

    for p in parents:
        if os.path.commonprefix([ _path, p ]) == p:
            for excl in excludes:
                if os.path.commonprefix([ _path, excl ]) == excl:
                    return False
            return True

    return False
Exemple #4
0
def is_parent_path(path, parents, excludes=[]):
    """Returns True if path is a child folder of one of the paths in parents, but not excluded under excludes"""
    _path = absdir(os.path.expanduser(os.path.expandvars(path)))
    if not _path:
        return False

    if not _path.endswith(os.path.sep):
        _path = _path + os.path.sep

    for p in parents:
        if os.path.commonprefix([_path, p]) == p:
            for excl in excludes:
                if os.path.commonprefix([_path, excl]) == excl:
                    return False
            return True

    return False
Exemple #5
0
    def test_want_file(self):
        # logging.getLogger('nose.selector').setLevel(logging.DEBUG)
        # logging.basicConfig()

        c = Config()
        c.where = [absdir(os.path.join(os.path.dirname(__file__), 'support'))]
        base = c.where[0]
        s = Selector(c)

        assert not s.wantFile('setup.py')
        assert not s.wantFile('/some/path/to/setup.py')
        assert not s.wantFile('ez_setup.py')
        assert not s.wantFile('.test.py')
        assert not s.wantFile('_test.py')
        assert not s.wantFile('setup_something.py')

        assert s.wantFile('test.py')
        assert s.wantFile('foo/test_foo.py')
        assert s.wantFile('bar/baz/test.py')
        assert not s.wantFile('foo.py')
        assert not s.wantFile('test_data.txt')
        assert not s.wantFile('data.text')
        assert not s.wantFile('bar/baz/__init__.py')
Exemple #6
0
    def test_want_file(self):

        #logging.getLogger('nose.selector').setLevel(logging.DEBUG)
        #logging.basicConfig()
        
        c = Config()
        c.where = [absdir(os.path.join(os.path.dirname(__file__), 'support'))]
        base = c.where[0]
        s = Selector(c)

        assert not s.wantFile('setup.py')
        assert not s.wantFile('/some/path/to/setup.py')
        assert not s.wantFile('ez_setup.py')
        assert not s.wantFile('.test.py')
        assert not s.wantFile('_test.py')
        assert not s.wantFile('setup_something.py')
        
        assert s.wantFile('test.py')
        assert s.wantFile('foo/test_foo.py')
        assert s.wantFile('bar/baz/test.py')
        assert not s.wantFile('foo.py')
        assert not s.wantFile('test_data.txt')
        assert not s.wantFile('data.text')
        assert not s.wantFile('bar/baz/__init__.py')
def normalize_path(path):
    _path = absdir(path)
    if not _path:
        return ''
    return (_path + os.path.sep) if not path.endswith(os.path.sep) else _path
def normalize_path(path):
    _path = absdir(path)
    if not _path:
        return ''
    return (_path + os.path.sep) if not path.endswith(os.path.sep) else _path