aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2023-08-07 01:05:27 +0100
committerSam James <sam@gentoo.org>2023-08-07 01:06:39 +0100
commitf1f43b235cec228fa0e478f389225729ae2ea3f8 (patch)
treef7122b3ad25a751ede7f486a9fb96a7359472a16 /tests/test_write_make_conf.py
parentModernise shebang (diff)
downloadmirrorselect-f1f43b235cec228fa0e478f389225729ae2ea3f8.tar.gz
mirrorselect-f1f43b235cec228fa0e478f389225729ae2ea3f8.tar.bz2
mirrorselect-f1f43b235cec228fa0e478f389225729ae2ea3f8.zip
Reformat with `black`
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'tests/test_write_make_conf.py')
-rw-r--r--tests/test_write_make_conf.py92
1 files changed, 49 insertions, 43 deletions
diff --git a/tests/test_write_make_conf.py b/tests/test_write_make_conf.py
index 100c5ed..0deee69 100644
--- a/tests/test_write_make_conf.py
+++ b/tests/test_write_make_conf.py
@@ -10,46 +10,52 @@ from mirrorselect.output import Output
class WriteMakeConfTestCase(unittest.TestCase):
- def test_write_make_conf(self):
-
- def __do_it(var, mirror_string, make_conf, expected_result):
- tempdir = tempfile.mkdtemp()
- status_output = open(os.devnull, 'w')
- #print("------make_conf--------", make_conf, "----------------------")
- #print("*****expect*****\n", expected_result, "***********")
- try:
- config_path = os.path.join(tempdir, 'make.conf')
- with open(config_path, 'w') as f:
- f.write(make_conf)
- write_make_conf(Output(out=status_output), config_path, var, mirror_string)
- with open(config_path) as f:
- result = f.read()
- #print("!!!result!!!\n", result, "!!!!!!!!!!\n")
- self.assertEqual(result, "{}".format(expected_result).format(mirror_string))
- finally:
- shutil.rmtree(tempdir)
- status_output.close()
-
- var = 'GENTOO_MIRRORS'
- mirrors = (
- ('{}="a"'.format(var)),
- ('{}="a b"'.format(var)),
- ('{}="a b c"'.format(var)),
- )
-
- cases = (
- ('{}="foo\nbar"\n'.format(var), '{}\n'),
- ('\n{}="foo\nbar"\n'.format(var), '\n{}\n'),
- ('\n{}="foo bar"\n'.format(var), '\n{}\n'),
- ('\n{}="foo bar"\n\n'.format(var), '\n\n{}\n'),
- ('\n{}="foo \\\nbar"\n'.format(var), '\n{}\n'),
- ('\n\n{}="foo \\\nbar"\n'.format(var), '\n\n{}\n'),
- ('\n\n{}="foo \\\nbar"\na="b"\n'.format(var), '\n\na="b"\n{}\n'),
- ('\n\n{}="foo \\\n bar"\na="b"\n'.format(var), '\n\na="b"\n{}\n'),
- ('\n\n{}="foo \\\n bar\\\n baz"\na="b"\n'.format(var), '\n\na="b"\n{}\n'),
- ('', '{}\n'),
- )
-
- for mirror in mirrors:
- for make_conf, expected_result in cases:
- __do_it(var, mirror, make_conf, expected_result)
+ def test_write_make_conf(self):
+ def __do_it(var, mirror_string, make_conf, expected_result):
+ tempdir = tempfile.mkdtemp()
+ status_output = open(os.devnull, "w")
+ # print("------make_conf--------", make_conf, "----------------------")
+ # print("*****expect*****\n", expected_result, "***********")
+ try:
+ config_path = os.path.join(tempdir, "make.conf")
+ with open(config_path, "w") as f:
+ f.write(make_conf)
+ write_make_conf(
+ Output(out=status_output), config_path, var, mirror_string
+ )
+ with open(config_path) as f:
+ result = f.read()
+ # print("!!!result!!!\n", result, "!!!!!!!!!!\n")
+ self.assertEqual(
+ result, "{}".format(expected_result).format(mirror_string)
+ )
+ finally:
+ shutil.rmtree(tempdir)
+ status_output.close()
+
+ var = "GENTOO_MIRRORS"
+ mirrors = (
+ ('{}="a"'.format(var)),
+ ('{}="a b"'.format(var)),
+ ('{}="a b c"'.format(var)),
+ )
+
+ cases = (
+ ('{}="foo\nbar"\n'.format(var), "{}\n"),
+ ('\n{}="foo\nbar"\n'.format(var), "\n{}\n"),
+ ('\n{}="foo bar"\n'.format(var), "\n{}\n"),
+ ('\n{}="foo bar"\n\n'.format(var), "\n\n{}\n"),
+ ('\n{}="foo \\\nbar"\n'.format(var), "\n{}\n"),
+ ('\n\n{}="foo \\\nbar"\n'.format(var), "\n\n{}\n"),
+ ('\n\n{}="foo \\\nbar"\na="b"\n'.format(var), '\n\na="b"\n{}\n'),
+ ('\n\n{}="foo \\\n bar"\na="b"\n'.format(var), '\n\na="b"\n{}\n'),
+ (
+ '\n\n{}="foo \\\n bar\\\n baz"\na="b"\n'.format(var),
+ '\n\na="b"\n{}\n',
+ ),
+ ("", "{}\n"),
+ )
+
+ for mirror in mirrors:
+ for make_conf, expected_result in cases:
+ __do_it(var, mirror, make_conf, expected_result)