From 06ebf384650d888f83cad74d41d5b8331b4ac394 Mon Sep 17 00:00:00 2001 From: PrajwalM2212 Date: Sat, 13 Jul 2019 00:28:53 +0530 Subject: [PATCH] Generate config files in TOML This PR provides coala-quickstart the flexibity to generate configuration files in TOML Closes https://github.com/coala/coala-quickstart/issues/336 --- .ci/appveyor.yml | 2 +- .ci/deps.python-packages.ps1 | 3 +- .moban.yaml | 5 +- coala_quickstart/coala_quickstart.py | 19 ++- coala_quickstart/generation/Settings.py | 32 +++- coala_quickstart/green_mode/green_mode.py | 85 ++++++--- .../green_mode/green_mode_core.py | 7 +- requirements.txt | 3 +- tests/generation/BearsTest.py | 27 +++ tests/green_mode/green_modeTest.py | 161 ++++++++++++++++-- 10 files changed, 291 insertions(+), 53 deletions(-) diff --git a/.ci/appveyor.yml b/.ci/appveyor.yml index 97c41c8..a8ac174 100644 --- a/.ci/appveyor.yml +++ b/.ci/appveyor.yml @@ -117,7 +117,7 @@ test_script: python setup.py install - python -m pip install - git+https://github.com/coala/coala#egg=coala + git+https://github.com/PrajwalM2212/coala.git@writer#egg=coala git+https://github.com/coala/coala-bears#egg=coala-bears diff --git a/.ci/deps.python-packages.ps1 b/.ci/deps.python-packages.ps1 index 7055fe1..3656c44 100644 --- a/.ci/deps.python-packages.ps1 +++ b/.ci/deps.python-packages.ps1 @@ -91,7 +91,8 @@ function Install-coala { Checkpoint-Pip-Constraints - Install-Pip-Requirement 'git+https://github.com/coala/coala#egg=coala' + Install-Pip-Requirement 'git+https://github.com/PrajwalM2212/coala.git@writer#egg=coala +' if (!($stop_at -eq 'coala-bears')) { Write-Output "Installing coala-bears" diff --git a/.moban.yaml b/.moban.yaml index 9ae4b75..36ab92b 100644 --- a/.moban.yaml +++ b/.moban.yaml @@ -28,8 +28,9 @@ entry_points: - coala-quickstart = coala_quickstart.coala_quickstart:main dependencies: - - 'git+https://github.com/coala/coala#egg=coala' - - 'git+https://github.com/coala/coala-bears#egg=coala-bears' + - git+https://gitlab.com/coala/coala-utils#egg=coala-utils + - git+https://github.com/coala/coala-bears#egg=coala-bears + - git+https://github.com/PrajwalM2212/coala.git@writer#egg=coala - gemfileparser~=0.6.2 - pyjsparser~=2.4.5 diff --git a/coala_quickstart/coala_quickstart.py b/coala_quickstart/coala_quickstart.py index 3bba53c..5af394a 100644 --- a/coala_quickstart/coala_quickstart.py +++ b/coala_quickstart/coala_quickstart.py @@ -26,7 +26,7 @@ remove_unusable_bears, ) from coala_quickstart.generation.Settings import ( - generate_settings, write_coafile) + generate_settings, write_coafile, write_toml_file) from coala_quickstart.generation.SettingsClass import ( collect_bear_settings) from coala_quickstart.green_mode.green_mode_core import green_mode @@ -52,6 +52,11 @@ def _get_arg_parser(): '-C', '--non-interactive', const=True, action='store_const', help='run coala-quickstart in non interactive mode') + arg_parser.add_argument('-T', '--toml-config', const=True, + action='store_const', + help='generate TOML config file ' + 'from coala-quickstart') + arg_parser.add_argument( '--ci', action='store_const', dest='non_interactive', const=True, help='continuous integration run, alias for `--non-interactive`') @@ -86,7 +91,7 @@ def _get_arg_parser(): def main(): - global MAX_ARGS_GREEN_MODE, MAX_VALUES_GREEN_MODE + global MAX_ARGS_GREEN_MODE, MAX_VALUES_GREEN_MODE, IN_TOML arg_parser = _get_arg_parser() args = arg_parser.parse_args() @@ -104,6 +109,10 @@ def main(): MAX_ARGS_GREEN_MODE = args.max_args if args.max_values: MAX_VALUES_GREEN_MODE = args.max_values + if args.toml_config: + IN_TOML = True + else: + IN_TOML = False if not args.green_mode and (args.max_args or args.max_values): logging.warning(' --max-args and --max-values can be used ' @@ -143,6 +152,7 @@ def main(): project_dir, ignore_globs, relevant_bears, bear_settings_obj, MAX_ARGS_GREEN_MODE, MAX_VALUES_GREEN_MODE, + IN_TOML, project_files, printer, ) @@ -163,4 +173,7 @@ def main(): extracted_information, args.incomplete_sections) - write_coafile(printer, project_dir, settings) + if args.toml_config: + write_toml_file(printer, project_dir, settings) + else: + write_coafile(printer, project_dir, settings) diff --git a/coala_quickstart/generation/Settings.py b/coala_quickstart/generation/Settings.py index 7825f3c..688d91b 100644 --- a/coala_quickstart/generation/Settings.py +++ b/coala_quickstart/generation/Settings.py @@ -2,6 +2,7 @@ from collections import OrderedDict from datetime import date +from coalib.output.ConfigConverter import ConfigConverter from coalib.settings.SectionFilling import fill_settings from coala_quickstart.generation.SettingsFilling import ( fill_section, acquire_settings) @@ -9,6 +10,7 @@ split_by_language, get_extensions) from coalib.settings.Section import Section from coalib.output.ConfWriter import ConfWriter +from tomlkit import comment def generate_section(section_name, extensions_used, bears): @@ -153,7 +155,7 @@ def write_coafile(printer, project_dir, settings): coafile = os.path.join(project_dir, '.coafile') if os.path.isfile(coafile): printer.print("'" + coafile + "' already exists.\nThe settings will be" - " written to '" + coafile + ".new'", + " written to '" + coafile + ".new'", color='yellow') coafile = coafile + '.new' @@ -163,3 +165,31 @@ def write_coafile(printer, project_dir, settings): writer.close() printer.print("'" + coafile + "' successfully generated.", color='green') + + +def write_toml_file(printer, project_dir, settings): + """ + Writes the .coafile.toml to disk. + + :param printer: + A ``ConsolePrinter`` object used for console interactions. + :param project_dir: + Full path of the user's project directory. + :param settings: + A dict with section name as key and a ``Section`` object as value. + """ + generation_date = date.today().strftime('%d %b %Y') + generation_comment = ('Generated by coala-quickstart on ' + '{date}.\n'.format(date=generation_date)) + + toml_file = os.path.join(project_dir, '.coafile.toml') + if os.path.isfile(toml_file): + printer.print("'" + toml_file + "' already exists.\nThe settings will" + " be written to '" + + ".coafile.new.toml'", + color='yellow') + toml_file = '.coafile.new.toml' + writer = ConfigConverter(toml_file) + writer.document.add(comment(generation_comment)) + writer.coafile_to_toml(settings) + printer.print("'" + toml_file + "' successfully generated.", color='green') diff --git a/coala_quickstart/green_mode/green_mode.py b/coala_quickstart/green_mode/green_mode.py index 765927d..224c092 100644 --- a/coala_quickstart/green_mode/green_mode.py +++ b/coala_quickstart/green_mode/green_mode.py @@ -3,6 +3,7 @@ import operator import os import sys +from collections import OrderedDict from copy import deepcopy from pathlib import Path @@ -11,36 +12,33 @@ get_all_args, get_extensions, get_yaml_contents, - peek, split_by_language, - ) -from coala_quickstart.generation.SettingsClass import ( - SettingTypes, - ) +) + from coala_quickstart.green_mode.file_aggregator import ( aggregate_files, - ) +) from coala_quickstart.green_mode.Setting import ( find_max_min_of_setting, - ) +) from coala_quickstart.generation.Settings import ( generate_ignore_field, - ) +) from coala_quickstart.green_mode.QuickstartBear import ( QuickstartBear, - ) +) from coala_utils.string_processing.Core import ( escape, - ) +) from coalib.bears.GlobalBear import GlobalBear from coalib.output.ConfWriter import ConfWriter +from coalib.output.ConfigConverter import ConfigConverter from coalib.processes.Processing import ( get_file_dict, yield_ignore_ranges, - ) +) from coalib.settings.Section import Section - settings_key = 'green_mode_infinite_value_settings' _CI_PYTEST_ACTIVE = os.environ.get('CI') and os.environ.get('PYTEST') _PYTHON_VERSION_MINOR = sys.version_info[0:2] @@ -72,20 +70,20 @@ def initialize_project_data(dir, ignore_globs): """ files_dirs = os.listdir(dir) # files_dirs holds names of both files and dirs. - dir_name = dir[dir.rfind(os.sep)+1:] + dir_name = dir[dir.rfind(os.sep) + 1:] final_data = [] for i in files_dirs: to_continue = False for glob in ignore_globs: - if fnmatch.fnmatch(dir+i, glob): + if fnmatch.fnmatch(dir + i, glob): to_continue = True if to_continue is True: continue - if os.path.isfile(dir+i): + if os.path.isfile(dir + i): final_data.append(i) else: - look_into_dir = dir+i+os.sep + look_into_dir = dir + i + os.sep data = initialize_project_data(look_into_dir, ignore_globs) final_data.append({i: data}) @@ -114,7 +112,7 @@ def generate_complete_filename_list(contents, project_dir): file_names_list.append(prefix + item) else: file_names_list += generate_complete_filename_list( - item[next(iter(item))], prefix+next(iter(item))) + item[next(iter(item))], prefix + next(iter(item))) return file_names_list @@ -213,7 +211,7 @@ def get_setting_type(setting, bear, dir=None): """ __location__ = os.path.realpath( os.path.join(os.getcwd(), os.path.dirname(__file__))) if ( - dir is None) else dir + dir is None) else dir bear_settings = get_yaml_contents(os.path.join( __location__, 'bear_settings.yaml')) for type_setting in bear_settings: @@ -481,8 +479,8 @@ def bear_test_fun(bears, bear_settings_obj, file_dict, ignore_ranges, bear, file_dict, file_names, lang, non_op_kwargs, ignore_ranges, 'non-op', printer, jobs=jobs, - ) - if len(op_kwargs) < op_args_limit and not( + ) + if len(op_kwargs) < op_args_limit and not ( True in [len(value) > value_to_op_args_limit for key, value in op_kwargs.items()]): unified_kwargs = dict(non_op_kwargs) @@ -492,7 +490,7 @@ def bear_test_fun(bears, bear_settings_obj, file_dict, ignore_ranges, unified_kwargs, ignore_ranges, 'unified', printer, jobs=jobs, - ) + ) else: unified_file_results = None final_non_op_results.append(non_op_file_results) @@ -597,8 +595,31 @@ def write_sections(self, sections): self.write_section(individual_section) +def write_toml_sections(self, sections): + sections_dict = OrderedDict() + + if not sections['all'] == []: + all_section = sections['all'][0] + ignore_all = all_section['ignore'] + sections_dict[all_section.name] = all_section + del sections['all'] + else: + all_section = '' + ignore_all = '' + + for section in sections: + for individual_section in sections[section]: + individual_section.defaults = all_section + if not ignore_all == '': + individual_section['ignore'] = str( + ignore_all) + ', ' + str(individual_section['ignore']) + sections_dict[individual_section.name] = individual_section + self.coafile_to_toml(sections_dict) + + def generate_green_mode_sections(data, project_dir, project_files, - ignore_globs, printer=None, suffix=''): + ignore_globs, in_toml, printer=None, + suffix=''): """ Generates the section objects for the green_mode. :param data: @@ -610,6 +631,8 @@ def generate_green_mode_sections(data, project_dir, project_files, List of paths to only the files inside the project directory. :param ignore_globs: The globs of files to ignore. + :param in_toml: + Decides whether to generate configuration files in toml or not :param printer: The ConsolePrinter object. :param suffix: @@ -658,8 +681,16 @@ def generate_green_mode_sections(data, project_dir, project_files, new_bear_sections.append(section) all_sections[bear.__name__] = new_bear_sections - coafile = os.path.join(project_dir, '.coafile.green' + suffix) - writer = ConfWriter(coafile) - write_sections(writer, all_sections) - writer.close() - printer.print("'" + coafile + "' successfully generated.", color='green') + if in_toml: + toml_file = os.path.join(project_dir, '.coafile.green.toml' + suffix) + writer = ConfigConverter(toml_file) + write_toml_sections(writer, all_sections) + printer.print("'" + toml_file + "' successfully generated.", + color='green') + else: + coafile = os.path.join(project_dir, '.coafile.green' + suffix) + writer = ConfWriter(coafile) + write_sections(writer, all_sections) + writer.close() + printer.print("'" + coafile + "' successfully generated.", + color='green') diff --git a/coala_quickstart/green_mode/green_mode_core.py b/coala_quickstart/green_mode/green_mode_core.py index 609b18e..a3439e2 100644 --- a/coala_quickstart/green_mode/green_mode_core.py +++ b/coala_quickstart/green_mode/green_mode_core.py @@ -19,7 +19,7 @@ def green_mode(project_dir: str, ignore_globs, bears, bear_settings_obj, - op_args_limit, value_to_op_args_limit, project_files, + op_args_limit, value_to_op_args_limit, in_toml, project_files, printer=None): """ Runs the green mode of coala-quickstart. @@ -44,6 +44,8 @@ def green_mode(project_dir: str, ignore_globs, bears, bear_settings_obj, about whether a setting takes a boolean value or any other value. :param op_args_limit: The maximum number of optional bear arguments allowed for guessing. + :param in_toml: + Decides whether to generate configuration file in toml or not :param project_files: The list of files in the project. :param value_to_op_args_limit: @@ -95,7 +97,8 @@ def green_mode(project_dir: str, ignore_globs, bears, bear_settings_obj, settings_unified[bear] = settings_non_op[bear] generate_green_mode_sections( - settings_unified, project_dir, project_files, ignore_globs, printer) + settings_unified, project_dir, project_files, ignore_globs, + in_toml, printer) # Final Dump. dump_yaml_to_file(project_data, project_data_contents) diff --git a/requirements.txt b/requirements.txt index 517d9b3..46e8d6f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -git+https://github.com/coala/coala#egg=coala +git+https://gitlab.com/coala/coala-utils#egg=coala-utils git+https://github.com/coala/coala-bears#egg=coala-bears +git+https://github.com/PrajwalM2212/coala.git@writer#egg=coala gemfileparser~=0.6.2 pyjsparser~=2.4.5 diff --git a/tests/generation/BearsTest.py b/tests/generation/BearsTest.py index b9da3d6..45f5410 100644 --- a/tests/generation/BearsTest.py +++ b/tests/generation/BearsTest.py @@ -346,6 +346,19 @@ def test_bears_allow_incomplete_sections_mode(self): os.remove('.coafile') os.chdir(orig_cwd) + def test_bears_allow_incomplete_sections_toml_mode(self): + sys.argv.append('--ci') + sys.argv.append('-T') + sys.argv.append('--allow-incomplete-sections') + orig_cwd = os.getcwd() + os.chdir(os.path.dirname(os.path.realpath(__file__))) + os.chdir("bears_ci_testfiles") + with retrieve_stdout() as custom_stdout: + main() + self.assertNotIn("usable", + custom_stdout.getvalue()) + os.chdir(orig_cwd) + def test_bears_ci_mode(self): sys.argv.append('--ci') orig_cwd = os.getcwd() @@ -358,6 +371,20 @@ def test_bears_ci_mode(self): os.remove('.coafile') os.chdir(orig_cwd) + def test_bears_ci_toml_mode(self): + sys.argv.append('--ci') + sys.argv.append('-T') + orig_cwd = os.getcwd() + os.chdir(os.path.dirname(os.path.realpath(__file__))) + os.chdir("bears_ci_testfiles") + with retrieve_stdout() as custom_stdout: + main() + self.assertIn("usable", + custom_stdout.getvalue()) + os.remove('.coafile.toml') + os.remove('.coafile.new.toml') + os.chdir(orig_cwd) + def test_bears_no_filter_by_capability_mode(self): languages = [] with bear_test_module(): diff --git a/tests/green_mode/green_modeTest.py b/tests/green_mode/green_modeTest.py index 7795a01..526b82c 100644 --- a/tests/green_mode/green_modeTest.py +++ b/tests/green_mode/green_modeTest.py @@ -9,10 +9,10 @@ from coala_quickstart.generation.SettingsClass import ( collect_bear_settings, - ) +) from coala_quickstart.green_mode.Setting import ( find_max_min_of_setting, - ) +) from coala_quickstart.green_mode import green_mode from coala_quickstart.green_mode.green_mode import ( bear_test_fun, @@ -26,23 +26,23 @@ initialize_project_data, local_bear_test, run_quickstartbear, - ) +) from coala_quickstart.generation.Utilities import ( append_to_contents, dump_yaml_to_file, get_yaml_contents, - ) +) from coala_quickstart.green_mode.QuickstartBear import ( QuickstartBear) from coalib.results.Result import Result from coalib.results.SourceRange import ( SourcePosition, SourceRange, - ) +) from coala_utils.string_processing.Core import escape from tests.test_bears.AllKindsOfSettingsDependentBear import ( AllKindsOfSettingsBaseBear, - ) +) from tests.test_bears.AnotherTestLocalDepBear import AnotherTestLocalDepBear from tests.test_bears.TestGlobalBear import TestGlobalBear from tests.test_bears.TestLocalBear import TestLocalBear @@ -433,20 +433,33 @@ def test_write_coafile(self): self.assertEqual(data_struct, test_data_struct) project_files = ['a.py', 'b.py', 'c.py', 'd.py'] coafile = '.coafile.green' + toml_file = '.coafile.green.toml' full_path = str(Path(__file__).parent.parent.parent) full_path_coafile = str(Path(__file__).parent.parent.parent / coafile) + full_path_toml = str(Path(__file__).parent.parent.parent / toml_file) + with patch('os.walk') as mockwalk: mockwalk.return_val = mockwalk.return_value = [ ('', (), ('a.py', 'b.py', 'c.py', 'd.py')), ] generate_green_mode_sections(data_struct, full_path, - project_files, ['x'], + project_files, ['x'], False, + printer) + generate_green_mode_sections(data_struct, full_path, + project_files, ['x'], True, printer) contents = "" with open(full_path_coafile) as f: for line in f.readlines(): contents += line + + contents_toml = "" + with open(full_path_toml) as f: + for line in f.readlines(): + contents_toml += line + full_path_glob = escape(full_path + os.sep + '**', '\\') + test_contents = dedent(""" [all] ignore = x @@ -468,26 +481,71 @@ def test_write_coafile(self): files = d.py, {full_path_glob} bears = TestLocalBear some_other_setting = x""").format( - full_path_glob=full_path_glob) + full_path_glob=full_path_glob) + + test_contents_toml = dedent(""" + [all] + ignore = "x" + + [TestLocalBear1] + some_setting = 3 + bears = "TestLocalBear" + ignore = ["a.py", "b.py", "c.py", "d.py"] + files = ["a.py", "b.py", \"{full_path_glob}\"] + inherits = ["all"] + appends.all = ["ignore"] + + [TestLocalBear2] + some_setting = 4 + bears = "TestLocalBear" + ignore = ["a.py", "b.py", "c.py", "d.py"] + files = ["c.py", \"{full_path_glob}\"] + inherits = ["all"] + appends.all = ["ignore"] + + [TestLocalBear3] + some_other_setting = "x" + bears = "TestLocalBear" + ignore = ["a.py", "b.py", "c.py", "d.py"] + files = ["d.py", \"{full_path_glob}\"] + inherits = ["all"] + appends.all = ["ignore"]""").format( + full_path_glob=full_path_glob) + # Since the order of settings within a seciton is volatile. - print('test_contents') for line in test_contents.split('\n'): if line == 'ignore = x': continue # Since the path depends on the test directory - self.assertIn(line, [i.strip('\\').replace('\\\\C', 'C') - for i in contents.split('\n')]) + self.assertIn(line, [i.strip('\\').replace('\\\\C', 'C') + for i in contents.split('\n')]) + + for line in test_contents_toml.split('\n'): + if line == 'ignore = "x"': + continue # Since the path depends on the test directory + self.assertIn(line, [i.strip('\\').replace('\\\\C', 'C') + for i in contents_toml.split('\n')]) with patch('os.walk') as mockwalk: mockwalk.return_val = mockwalk.return_value = [ ('', (), ('a.py', 'b.py', 'c.py', 'd.py')), ] generate_green_mode_sections(data_struct, full_path, - project_files, [], + project_files, [], False, + printer) + + generate_green_mode_sections(data_struct, full_path, + project_files, ['x'], True, printer) contents = "" with open(full_path_coafile) as f: for line in f.readlines(): contents += line + + contents_toml = "" + with open(full_path_toml) as f: + for line in f.readlines(): + contents_toml += line + # TODO: remove the prefix 'all.' from section names when section # all is not present which only happends when the ignore field # is empty. @@ -509,7 +567,37 @@ def test_write_coafile(self): files = d.py, {full_path_glob} bears = TestLocalBear some_other_setting = x""").format( - full_path_glob=full_path_glob) + full_path_glob=full_path_glob) + + test_contents_toml = dedent(""" + [all] + ignore = "x" + + [TestLocalBear1] + some_setting = 3 + bears = "TestLocalBear" + ignore = ["a.py", "b.py", "c.py", "d.py"] + files = ["a.py", "b.py", \"{full_path_glob}\"] + inherits = ["all"] + appends.all = ["ignore"] + + [TestLocalBear2] + some_setting = 4 + bears = "TestLocalBear" + ignore = ["a.py", "b.py", "c.py", "d.py"] + files = ["c.py", \"{full_path_glob}\"] + inherits = ["all"] + appends.all = ["ignore"] + + [TestLocalBear3] + some_other_setting = "x" + bears = "TestLocalBear" + ignore = ["a.py", "b.py", "c.py", "d.py"] + files = ["d.py", \"{full_path_glob}\"] + inherits = ["all"] + appends.all = ["ignore"]""").format( + full_path_glob=full_path_glob) + # Since the order of settings within a seciton is volatile. for line in test_contents.split('\n'): if line == 'ignore = x': @@ -517,6 +605,12 @@ def test_write_coafile(self): self.assertIn(line, [i.strip('\\').replace('\\\\C', 'C') for i in contents.split('\n')]) + for line in test_contents_toml.split('\n'): + if line == 'ignore = "x"': + continue # Since the path depends on the test directory + self.assertIn(line, [i.strip('\\').replace('\\\\C', 'C') + for i in contents_toml.split('\n')]) + test_data_struct = {TestLocalBear: [[{'filename': ['a.py', 'b.py'], 'some_setting': 3}, {'filename': ['c.py'], @@ -530,7 +624,10 @@ def test_write_coafile(self): mockwalk.return_val = mockwalk.return_value = [ ('', (), ('a.py', 'b.py', 'c.py', 'd.py')), ] generate_green_mode_sections(test_data_struct, full_path, - project_files, [], + project_files, [], False, + printer) + generate_green_mode_sections(test_data_struct, full_path, + project_files, [], True, printer) contents = "" @@ -538,6 +635,11 @@ def test_write_coafile(self): for line in f.readlines(): contents += line + contents_toml = "" + with open(full_path_toml) as f: + for line in f.readlines(): + contents_toml += line + # TODO: section name enumerations should not skip integers. test_contents = dedent(""" [all.TestLocalBear1] @@ -557,7 +659,30 @@ def test_write_coafile(self): files = d.py, {full_path_glob} bears = TestLocalBear some_other_setting = x""").format( - full_path_glob=full_path_glob) + full_path_glob=full_path_glob) + + test_contents_toml = dedent(""" + [TestLocalBear1] + ignore = ["a.py", "b.py", "c.py", "d.py"] + files = ["a.py", "b.py", \"{full_path_glob}\"] + bears = "TestLocalBear" + some_setting = 3 + inherits = ["all"] + + [TestLocalBear2] + ignore = ["a.py", "b.py", "c.py", "d.py"] + files = ["c.py", \"{full_path_glob}\"] + bears = "TestLocalBear" + some_setting = 4 + inherits = ["all"] + + [TestLocalBear4] + some_other_setting = "x" + bears = "TestLocalBear" + ignore = ["a.py", "b.py", "c.py", "d.py"] + files = ["d.py", \"{full_path_glob}\"] + inherits = ["all"]""").format( + full_path_glob=full_path_glob) # Since the order of settings within a seciton is volatile. for line in test_contents.split('\n'): @@ -566,6 +691,12 @@ def test_write_coafile(self): self.assertIn(line, [i.strip('\\').replace('\\\\C', 'C') for i in contents.split('\n')]) + for line in test_contents_toml.split('\n'): + if line == 'ignore = x': + continue # Since the path depends on the test directory + self.assertIn(line, [i.strip('\\').replace('\\\\C', 'C') + for i in contents_toml.split('\n')]) + class MultiProcessingTest(unittest.TestCase):