Esempio n. 1
0
    def test_pylintrc_parentdir_no_package(self):
        chroot = tempfile.mkdtemp()

        # Get real path of tempfile, otherwise test fail on mac os x
        cdir = getcwd()
        chdir(chroot)
        chroot = abspath('.')
        chdir(cdir)

        fake_home = tempfile.mkdtemp('fake-home')
        home = os.environ['HOME']
        os.environ['HOME'] = fake_home
        try:
            create_files(['a/pylintrc', 'a/b/pylintrc', 'a/b/c/d/__init__.py'], chroot)
            os.chdir(chroot)
            self.assertEqual(config.find_pylintrc(), None)
            results = {'a'       : join(chroot, 'a', 'pylintrc'),
                       'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                       'a/b/c'   : None,
                       'a/b/c/d' : None,
                       }
            for basedir, expected in results.items():
                os.chdir(join(chroot, basedir))
                self.assertEqual(config.find_pylintrc(), expected)
        finally:
            os.environ['HOME'] = home
            rmtree(fake_home, ignore_errors=True)
            os.chdir(HERE)
            rmtree(chroot)
 def test_pylintrc_parentdir(self):
     chroot = tempfile.mkdtemp()
     try:
         create_files(['a/pylintrc', 'a/b/__init__.py', 'a/b/pylintrc',
                       'a/b/c/__init__.py', 'a/b/c/d/__init__.py'], chroot)
         os.chdir(chroot)
         fake_home = tempfile.mkdtemp('fake-home')
         home = os.environ['HOME']
         try:
             os.environ['HOME'] = fake_home
             self.assertEqual(config.find_pylintrc(), None)
         finally:
             os.environ['HOME'] = home
             os.rmdir(fake_home)
         results = {'a'       : join(chroot, 'a', 'pylintrc'),
                    'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                    'a/b/c'   : join(chroot, 'a', 'b', 'pylintrc'),
                    'a/b/c/d' : join(chroot, 'a', 'b', 'pylintrc'),
                    }
         for basedir, expected in results.items():
             os.chdir(join(chroot, basedir))
             self.assertEqual(config.find_pylintrc(), expected)
     finally:
         os.chdir(HERE)
         rmtree(chroot)
    def test_pylintrc_parentdir_no_package(self):
        chroot = tempfile.mkdtemp()

        # Get real path of tempfile, otherwise test fail on mac os x
        cdir = getcwd()
        chdir(chroot)
        chroot = abspath('.')
        chdir(cdir)

        fake_home = tempfile.mkdtemp('fake-home')
        home = os.environ['HOME']
        os.environ['HOME'] = fake_home
        try:
            create_files(['a/pylintrc', 'a/b/pylintrc', 'a/b/c/d/__init__.py'], chroot)
            os.chdir(chroot)
            self.assertEqual(config.find_pylintrc(), None)
            results = {'a'       : join(chroot, 'a', 'pylintrc'),
                       'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                       'a/b/c'   : None,
                       'a/b/c/d' : None,
                       }
            for basedir, expected in results.items():
                os.chdir(join(chroot, basedir))
                self.assertEqual(config.find_pylintrc(), expected)
        finally:
            os.environ['HOME'] = home
            rmtree(fake_home, ignore_errors=True)
            os.chdir(HERE)
            rmtree(chroot)
 def test_pylintrc_parentdir(self):
     chroot = tempfile.mkdtemp()
     try:
         create_files([
             'a/pylintrc', 'a/b/__init__.py', 'a/b/pylintrc',
             'a/b/c/__init__.py', 'a/b/c/d/__init__.py'
         ], chroot)
         os.chdir(chroot)
         fake_home = tempfile.mkdtemp('fake-home')
         home = os.environ['HOME']
         try:
             os.environ['HOME'] = fake_home
             self.assertEqual(config.find_pylintrc(), None)
         finally:
             os.environ['HOME'] = home
             os.rmdir(fake_home)
         results = {
             'a': join(chroot, 'a', 'pylintrc'),
             'a/b': join(chroot, 'a', 'b', 'pylintrc'),
             'a/b/c': join(chroot, 'a', 'b', 'pylintrc'),
             'a/b/c/d': join(chroot, 'a', 'b', 'pylintrc'),
         }
         for basedir, expected in results.items():
             os.chdir(join(chroot, basedir))
             self.assertEqual(config.find_pylintrc(), expected)
     finally:
         os.chdir(HERE)
         rmtree(chroot)
Esempio n. 5
0
 def test_pylintrc_parentdir(self):
     chroot = tempfile.mkdtemp()
     try:
         create_files(
             ["a/pylintrc", "a/b/__init__.py", "a/b/pylintrc", "a/b/c/__init__.py", "a/b/c/d/__init__.py"], chroot
         )
         os.chdir(chroot)
         fake_home = tempfile.mkdtemp("fake-home")
         home = os.environ["HOME"]
         try:
             os.environ["HOME"] = fake_home
             self.assertEquals(config.find_pylintrc(), None)
         finally:
             os.environ["HOME"] = home
             os.rmdir(fake_home)
         results = {
             "a": join(chroot, "a", "pylintrc"),
             "a/b": join(chroot, "a", "b", "pylintrc"),
             "a/b/c": join(chroot, "a", "b", "pylintrc"),
             "a/b/c/d": join(chroot, "a", "b", "pylintrc"),
         }
         for basedir, expected in results.items():
             os.chdir(join(chroot, basedir))
             self.assertEquals(config.find_pylintrc(), expected)
     finally:
         os.chdir(HERE)
         rmtree(chroot)
 def test_pylintrc_parentdir_no_package(self):
     chroot = tempfile.mkdtemp()
     try:
         create_files(['a/pylintrc', 'a/b/pylintrc', 'a/b/c/d/__init__.py'], chroot)
         os.chdir(chroot)
         self.assertEquals(config.find_pylintrc(), None)
         results = {'a'       : join(chroot, 'a', 'pylintrc'),
                    'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                    'a/b/c'   : None, 
                    'a/b/c/d' : None, 
                    }
         for basedir, expected in results.items():
             os.chdir(join(chroot, basedir))
             self.assertEquals(config.find_pylintrc(), expected)
     finally:
         os.chdir(HERE)
         shutil.rmtree(chroot)
Esempio n. 7
0
 def test_create_files(self):
     chroot = tempfile.mkdtemp()
     path_to = lambda path: join(chroot, path)
     dircontent = lambda path: sorted(os.listdir(join(chroot, path)))
     try:
         self.assertFalse(isdir(path_to('a/')))
         create_files(['a/b/foo.py', 'a/b/c/', 'a/b/c/d/e.py'], chroot)
         # make sure directories exist
         self.assertTrue(isdir(path_to('a')))
         self.assertTrue(isdir(path_to('a/b')))
         self.assertTrue(isdir(path_to('a/b/c')))
         self.assertTrue(isdir(path_to('a/b/c/d')))
         # make sure files exist
         self.assertTrue(isfile(path_to('a/b/foo.py')))
         self.assertTrue(isfile(path_to('a/b/c/d/e.py')))
         # make sure only asked files were created
         self.assertEqual(dircontent('a'), ['b'])
         self.assertEqual(dircontent('a/b'), ['c', 'foo.py'])
         self.assertEqual(dircontent('a/b/c'), ['d'])
         self.assertEqual(dircontent('a/b/c/d'), ['e.py'])
     finally:
         shutil.rmtree(chroot)
Esempio n. 8
0
 def test_create_files(self):
     chroot = tempfile.mkdtemp()
     path_to = lambda path: join(chroot, path)
     dircontent = lambda path: sorted(os.listdir(join(chroot, path)))
     try:
         self.failIf(isdir(path_to('a/')))
         create_files(['a/b/foo.py', 'a/b/c/', 'a/b/c/d/e.py'], chroot)
         # make sure directories exist
         self.failUnless(isdir(path_to('a')))
         self.failUnless(isdir(path_to('a/b')))
         self.failUnless(isdir(path_to('a/b/c')))
         self.failUnless(isdir(path_to('a/b/c/d')))
         # make sure files exist
         self.failUnless(isfile(path_to('a/b/foo.py')))
         self.failUnless(isfile(path_to('a/b/c/d/e.py')))
         # make sure only asked files were created
         self.assertEquals(dircontent('a'), ['b'])
         self.assertEquals(dircontent('a/b'), ['c', 'foo.py'])
         self.assertEquals(dircontent('a/b/c'), ['d'])
         self.assertEquals(dircontent('a/b/c/d'), ['e.py'])
     finally:
         shutil.rmtree(chroot)
Esempio n. 9
0
 def test_create_files(self):
     chroot = tempfile.mkdtemp()
     path_to = lambda path: join(chroot, path)
     dircontent = lambda path: sorted(os.listdir(join(chroot, path)))
     try:
         self.assertFalse(isdir(path_to("a/")))
         create_files(["a/b/foo.py", "a/b/c/", "a/b/c/d/e.py"], chroot)
         # make sure directories exist
         self.assertTrue(isdir(path_to("a")))
         self.assertTrue(isdir(path_to("a/b")))
         self.assertTrue(isdir(path_to("a/b/c")))
         self.assertTrue(isdir(path_to("a/b/c/d")))
         # make sure files exist
         self.assertTrue(isfile(path_to("a/b/foo.py")))
         self.assertTrue(isfile(path_to("a/b/c/d/e.py")))
         # make sure only asked files were created
         self.assertEqual(dircontent("a"), ["b"])
         self.assertEqual(dircontent("a/b"), ["c", "foo.py"])
         self.assertEqual(dircontent("a/b/c"), ["d"])
         self.assertEqual(dircontent("a/b/c/d"), ["e.py"])
     finally:
         shutil.rmtree(chroot)