def lib_compile_pyc(folder, remove_py=False): from test.base import get_pyconcrete_env_path admin_path = join(ROOT_DIR, 'pyconcrete-admin.py') arg_remove_py = '--remove-py' if remove_py else '' subprocess.check_call( '%s %s compile --source=%s --pyc %s' % (sys.executable, admin_path, folder, arg_remove_py), env=get_pyconcrete_env_path(), shell=True, )
def test_parse_file(self): target_dir = join(self.tmp_dir, 'data') shutil.copytree(SAMPLE_PACKAGE_DIR, target_dir) target_file = join(target_dir, 'main.py') expect_file = join(target_dir, 'main.pye') subprocess.check_call( '%s pyconcrete-admin.py compile --source=%s --pye' % (sys.executable, target_file), env=base.get_pyconcrete_env_path(), shell=True, ) self.assertTrue(exists(expect_file))
def test_pattern(pat): subprocess.check_call( ('%s pyconcrete-admin.py compile --source=%s --pye -i "%s"' % (sys.executable, self.tmp_dir, pat)), env=base.get_pyconcrete_env_path(), shell=True, ) msg = "pattern(%s) fail" % pat self.assertTrue(exists(expect_file1), msg) self.assertTrue(exists(expect_file2), msg) self.assertFalse(exists(expect_file3), msg) # test.py excluded self.assertTrue(exists(expect_file4), msg) self.assertTrue(exists(expect_file5), msg)
def test_parse_folder(self): target_dir = join(self.tmp_dir, 'data') # print 'src=%s, target=%s' % (SAMPLE_PACKAGE_DIR, target_dir) shutil.copytree(SAMPLE_PACKAGE_DIR, target_dir) expect_file1 = join(target_dir, '__init__.pye') expect_file2 = join(target_dir, 'main.pye') subprocess.check_call( '%s pyconcrete-admin.py compile --source=%s --pye' % (sys.executable, target_dir), env=base.get_pyconcrete_env_path(), shell=True, ) self.assertTrue(exists(expect_file1)) self.assertTrue(exists(expect_file2))
def test_ignore_file_list_match_not_in_seq(self): expect_file1 = join(self.tmp_dir, 'test1.pye') expect_file2 = join(self.tmp_dir, 'test2.pye') subprocess.check_call( ( '%s pyconcrete-admin.py compile --source=%s --pye -i main.py test[!1,3].py' % (sys.executable, self.tmp_dir) ), env=base.get_pyconcrete_env_path(), shell=True, ) self.assertTrue(exists(expect_file1)) self.assertFalse(exists(expect_file2))
def test_ignore_file_list_match_single(self): target_dir = join(self.tmp_dir, 'data') shutil.copytree(SAMPLE_PACKAGE_DIR, target_dir) expect_file1 = join(target_dir, '__init__.pye') expect_file2 = join(target_dir, 'main.pye') expect_file3 = join(self.tmp_dir, 'test1.pye') expect_file4 = join(self.tmp_dir, 'test2.pye') subprocess.check_call( ('%s pyconcrete-admin.py compile --source=%s --pye -i main.py test?.py' % (sys.executable, self.tmp_dir)), env=base.get_pyconcrete_env_path(), shell=True, ) self.assertTrue(exists(expect_file1)) self.assertFalse(exists(expect_file2)) self.assertFalse(exists(expect_file3)) self.assertFalse(exists(expect_file4))
def test_ignore_file_list_match_everything(self): target_dir = join(self.tmp_dir, 'data') relative_import_dir = join(self.tmp_dir, 'data', 'relative_import') shutil.copytree(SAMPLE_PACKAGE_DIR, target_dir) expect_file1 = join(target_dir, 'main.pye') # relative_import/util.pye expect_file2 = join(relative_import_dir, 'util.pye') # relative_import/main.pye expect_file3 = join(relative_import_dir, 'main.pye') subprocess.check_call( ('%s pyconcrete-admin.py compile --source=%s --pye -i relative_import/*' % (sys.executable, target_dir)), env=base.get_pyconcrete_env_path(), shell=True, ) self.assertTrue(exists(expect_file1)) self.assertFalse(exists(expect_file2)) self.assertFalse(exists(expect_file3))