Permalink
Browse files

.coafile: Add test files to default section

Adds ``tests/**.py`` to files in default section and
fixes all the syling mistakes in test files.

Closes to #113
  • Loading branch information...
satwikkansal committed Jun 22, 2017
1 parent 37573da commit 7ac90f0812a1c338defb5265e33085fce36c2e7a
View
@@ -1,5 +1,5 @@
[Default]
files = *.py, coala_quickstart/**/*.py
files = *.py, coala_quickstart/**/*.py, tests/**.py
ignore =
coalib/tests/bearlib/languages/documentation/documentation_extraction_testdata/data.py,
coalib/tests/collecting/collectors_test_dir/bears/incorrect_bear.py,
View
@@ -43,10 +43,10 @@ def test_bears_allow_incomplete_sections_mode(self):
os.chdir("bears_ci_testfiles")
with retrieve_stdout() as custom_stdout:
main()
self.assertNotIn("usable",
custom_stdout.getvalue())
self.assertNotIn("usable",
custom_stdout.getvalue())
os.remove('.coafile')
os.chdir(orig_cwd)
os.chdir(orig_cwd)
def test_bears_ci_mode(self):
sys.argv.append('--ci')
@@ -55,7 +55,7 @@ def test_bears_ci_mode(self):
os.chdir("bears_ci_testfiles")
with retrieve_stdout() as custom_stdout:
main()
self.assertIn("usable",
custom_stdout.getvalue())
self.assertIn("usable",
custom_stdout.getvalue())
os.remove('.coafile')
os.chdir(orig_cwd)
os.chdir(orig_cwd)
@@ -30,11 +30,16 @@ def test_get_project_files(self):
open(os.path.join("ignore_dir", "src.js"), "w").close()
with suppress_stdout(), simulate_console_inputs("ignore_dir/**"):
res, _ = get_project_files(self.log_printer, self.printer, os.getcwd())
self.assertIn(os.path.normcase(os.path.join(os.getcwd(), "src", "file.c")), res)
self.assertIn(os.path.normcase(os.path.join(os.getcwd(), "root.c")), res)
self.assertNotIn(os.path.normcase(os.path.join(os.getcwd(), "ignore_dir/src.c")), res)
self.assertNotIn(os.path.normcase(os.path.join(os.getcwd(), "ignore_dir/src.js")), res)
res, _ = get_project_files(
self.log_printer, self.printer, os.getcwd())
self.assertIn(os.path.normcase(
os.path.join(os.getcwd(), "src", "file.c")), res)
self.assertIn(os.path.normcase(
os.path.join(os.getcwd(), "root.c")), res)
self.assertNotIn(os.path.normcase(
os.path.join(os.getcwd(), "ignore_dir/src.c")), res)
self.assertNotIn(os.path.normcase(
os.path.join(os.getcwd(), "ignore_dir/src.js")), res)
os.chdir(orig_cwd)
@@ -57,21 +62,21 @@ def test_get_project_files_gitignore(self):
# End of gitignore""")
files = [os.path.join("src", "main.c"),
os.path.join("src", "main.h"),
os.path.join("src", "lib", "ssl.c"),
os.path.join("src", "tests", "main.c"),
os.path.join("src", "main.py"),
os.path.join("src", "upload.c"),
".coafile"]
os.path.join("src", "main.h"),
os.path.join("src", "lib", "ssl.c"),
os.path.join("src", "tests", "main.c"),
os.path.join("src", "main.py"),
os.path.join("src", "upload.c"),
".coafile"]
ignored_files = [os.path.join("build", "main.c"),
os.path.join("tests", "run.c"),
os.path.join("src", "build", "main.c"),
"ignore.c",
os.path.join("src", "ignore.c"),
"globexp.py",
"upload.c",
os.path.join("src", "main.pyc"),
"run.pyc"]
os.path.join("tests", "run.c"),
os.path.join("src", "build", "main.c"),
"ignore.c",
os.path.join("src", "ignore.c"),
"globexp.py",
"upload.c",
os.path.join("src", "main.pyc"),
"run.pyc"]
for file in files + ignored_files:
os.makedirs(os.path.dirname(os.path.abspath(file)), exist_ok=True)
@@ -97,15 +102,14 @@ def test_get_project_files_gitignore(self):
os.remove(".gitignore")
os.chdir(orig_cwd)
def test_get_project_files_ci_mode(self):
orig_cwd = os.getcwd()
os.chdir(os.path.dirname(os.path.realpath(__file__)) +
os.sep + "file_globs_ci_testfiles")
os.chdir(os.path.dirname(os.path.realpath(__file__)) +
os.sep + "file_globs_ci_testfiles")
with suppress_stdout():
res, _ = get_project_files(self.log_printer, self.printer, os.getcwd()
, True)
res, _ = get_project_files(
self.log_printer, self.printer, os.getcwd(), True)
paths = [
os.path.join(os.getcwd(), "src", "file.c"),
@@ -13,17 +13,17 @@ def setUp(self):
def test_get_used_languages(self):
file_lists = [["/tmp/file.py", "/tmp/file.py"],
["/tmp/file.py", "/tmp/test.cpp"],
["/tmp/file.py"],
["/tmp/file.py", "/tmp/unknown.extension"],
["/tmp/unknown.extension"],
[]]
["/tmp/file.py", "/tmp/test.cpp"],
["/tmp/file.py"],
["/tmp/file.py", "/tmp/unknown.extension"],
["/tmp/unknown.extension"],
[]]
results = [[('Python', 100)],
[('Python', 50), ('C++', 50)],
[('Python', 100)],
[('Python', 50)],
[],
[]]
[('Python', 50), ('C++', 50)],
[('Python', 100)],
[('Python', 50)],
[],
[]]
for file_list, expected_result in zip(file_lists, results):
result = get_used_languages(file_list)
@@ -18,22 +18,22 @@ def setUp(self):
self.writer = ConfWriter(self.coafile)
self.old_argv = deepcopy(sys.argv)
del sys.argv[1:]
def tearDown(self):
self.writer.close()
os.remove(self.coafile)
sys.argv = self.old_argv
def test_write_info(self):
result_date = date.today().strftime("%d %b %Y")
result_comment = ('# Generated by coala-quickstart on '
'{date}.\n'.format(date=result_date))
write_info(self.writer)
self.writer.close()
with open(self.coafile, 'r') as f:
line = f.readline()
self.assertEqual(result_comment, line)
def test_allow_complete_section_mode(self):
@@ -51,8 +51,10 @@ def test_allow_complete_section_mode(self):
files_list = res["HTML"]["files"].value.replace(" ", "").split(",")
self.assertEqual(['HTMLLintBear', 'coalaBear', 'BootLintBear',
'LicenseCheckBear', 'SpaceConsistencyBear', 'KeywordBear',
'LineLengthBear', 'DuplicateFileBear'].sort(), bears_list.sort())
self.assertEqual(
['HTMLLintBear', 'coalaBear', 'BootLintBear',
'LicenseCheckBear', 'SpaceConsistencyBear', 'KeywordBear',
'LineLengthBear', 'DuplicateFileBear'].sort(),
bears_list.sort())
self.assertEqual(['**.html'], files_list)
@@ -28,7 +28,6 @@ def find_information(self, fname, parsed_file):
fname,
'Dummy information it is!')]
class DummyMultiInfoExtractor(InfoExtractor):
def parse_file(self, fname, file_content):
@@ -135,7 +134,6 @@ def test_multiple_target_globs(self):
extracted_info[tf]['DummyInfo'][0].extractor,
InfoExtractor)
def test_multiple_information(self):
target_filenames = ['target_file_1', ]
@@ -259,8 +257,8 @@ def test_supported_info_kinds(self):
self.current_dir) as gen_files:
uut = self.WrongSupportedInfoExtractor(
['target_file_**'],
self.current_dir)
['target_file_**'],
self.current_dir)
with self.assertRaisesRegexp(
ValueError,
@@ -26,6 +26,7 @@
Some content that is not JSON!
"""
class PackageJSONInfoExtractorTest(unittest.TestCase):
def setUp(self):
@@ -63,7 +64,8 @@ def test_extracted_information(self):
self.assertIn("ManFilesInfo", information_types)
man_paths_info = extracted_information["ManFilesInfo"]
self.assertEqual(len(man_paths_info), 1)
self.assertEqual(man_paths_info[0].value, ["./man/foo.1", "./man/bar.1"])
self.assertEqual(man_paths_info[0].value,
["./man/foo.1", "./man/bar.1"])
self.assertIn("IncludePathsInfo", information_types)
include_paths_info = extracted_information["IncludePathsInfo"]
@@ -21,7 +21,8 @@ def test_print_side_by_side(self):
"left side."],
limit=80)
self.assertIn(
"side content.\x1b[0m \x1b[34mRight side", custom_stdout.getvalue())
"side content.\x1b[0m \x1b[34mRight side",
custom_stdout.getvalue())
def test_print_welcome_message(self):
with retrieve_stdout() as custom_stdout:

0 comments on commit 7ac90f0

Please sign in to comment.