Exemplo n.º 1
0
    def test_get_globs(self):
        """Test example.get_glob()."""
        self.assertFalse(os.path.isdir('/test'))
        self.fs.CreateDirectory('/test/dir1/dir2a')
        self.assertTrue(os.path.isdir('/test/dir1/dir2a'))
        # os.mkdirs() works, too.
        os.makedirs('/test/dir1/dir2b')
        self.assertTrue(os.path.isdir('/test/dir1/dir2b'))

        self.assertEqual(example.get_glob('/test/dir1/nonexistent*'),
                         [])
        is_windows = sys.platform.startswith('win')
        matching_paths = sorted(example.get_glob('/test/dir1/dir*'))
        if is_windows:
            self.assertEqual(matching_paths, [r'\test\dir1\dir2a', r'\test\dir1\dir2b'])
        else:
            self.assertEqual(matching_paths, ['/test/dir1/dir2a', '/test/dir1/dir2b'])
    def test_get_globs(self):
        '''Test example.get_glob()
        
        `self.fs.CreateDirectory()` creates directories.  However, you might
        prefer the familiar `os.makedirs()`, which also works fine on the fake
        file system.
        '''
        self.assertFalse(os.path.isdir('/test'))
        self.fs.CreateDirectory('/test/dir1/dir2a')
        self.assertTrue(os.path.isdir('/test/dir1/dir2a'))
        # os.mkdirs() works, too.
        os.makedirs('/test/dir1/dir2b')
        self.assertTrue(os.path.isdir('/test/dir1/dir2b'))

        self.assertCountEqual(example.get_glob('/test/dir1/nonexistent*'), [])
        self.assertCountEqual(example.get_glob('/test/dir1/dir*'),
                              ['/test/dir1/dir2a', '/test/dir1/dir2b'])
Exemplo n.º 3
0
 def test_get_globs(self):
     '''Test example.get_glob()
     
     `self.fs.CreateDirectory()` creates directories.  However, you might
     prefer the familiar `os.makedirs()`, which also works fine on the fake
     file system.
     '''
     self.assertFalse(os.path.isdir('/test'))
     self.fs.CreateDirectory('/test/dir1/dir2a')
     self.assertTrue(os.path.isdir('/test/dir1/dir2a'))
     # os.mkdirs() works, too.
     os.makedirs('/test/dir1/dir2b')
     self.assertTrue(os.path.isdir('/test/dir1/dir2b'))
     
     self.assertItemsEqual(example.get_glob('/test/dir1/nonexistent*'),
                           [])
     self.assertItemsEqual(example.get_glob('/test/dir1/dir*'),
                           ['/test/dir1/dir2a', '/test/dir1/dir2b'])
Exemplo n.º 4
0
    def test_get_globs(self):
        '''Test example.get_glob()

        `self.fs.CreateDirectory()` creates directories.  However, you might
        prefer the familiar `os.makedirs()`, which also works fine on the fake
        file system.
        '''
        self.assertFalse(os.path.isdir('/test'))
        self.fs.CreateDirectory('/test/dir1/dir2a')
        self.assertTrue(os.path.isdir('/test/dir1/dir2a'))
        # os.mkdirs() works, too.
        os.makedirs('/test/dir1/dir2b')
        self.assertTrue(os.path.isdir('/test/dir1/dir2b'))

        self.assertEqual(example.get_glob('/test/dir1/nonexistent*'), [])
        is_windows = sys.platform.startswith('win')
        matching_paths = example.get_glob('/test/dir1/dir*')
        if is_windows:
            self.assertEqual(matching_paths,
                             [r'\test\dir1\dir2a', r'\test\dir1\dir2b'])
        else:
            self.assertEqual(matching_paths,
                             ['/test/dir1/dir2a', '/test/dir1/dir2b'])