Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Warren <bmw@users.noreply.github.com>2020-02-27 21:50:20 +0300
committerGitHub <noreply@github.com>2020-02-27 21:50:20 +0300
commita2be8e1956c79662fd28d8b8af4802ea89cf29bf (patch)
tree86ee69e7594e5755cf726728a5f7e9f2f7381bde
parent2f737ee292680e2f8043e0dfe3affcccc03914e8 (diff)
Fix tests on macOS Catalina (#7794)
This PR fixes the failures that can be seen at https://dev.azure.com/certbot/certbot/_build/results?buildId=1184&view=results. You can see this code running on macOS Catalina at https://dev.azure.com/certbot/certbot/_build/results?buildId=1192&view=results.
-rw-r--r--certbot/tests/cli_test.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/certbot/tests/cli_test.py b/certbot/tests/cli_test.py
index 3a7fb57f8..be2c8f29e 100644
--- a/certbot/tests/cli_test.py
+++ b/certbot/tests/cli_test.py
@@ -30,15 +30,23 @@ class TestReadFile(TempDirTestCase):
# However a relative path between two different drives is invalid. So we move to
# self.tempdir to ensure that we stay on the same drive.
os.chdir(self.tempdir)
- rel_test_path = os.path.relpath(os.path.join(self.tempdir, 'foo'))
+ # The read-only filesystem introduced with macOS Catalina can break
+ # code using relative paths below. See
+ # https://bugs.python.org/issue38295 for another example of this.
+ # Eliminating any possible symlinks in self.tempdir before passing
+ # it to os.path.relpath solves the problem. This is done by calling
+ # filesystem.realpath which removes any symlinks in the path on
+ # POSIX systems.
+ real_path = filesystem.realpath(os.path.join(self.tempdir, 'foo'))
+ relative_path = os.path.relpath(real_path)
self.assertRaises(
- argparse.ArgumentTypeError, cli.read_file, rel_test_path)
+ argparse.ArgumentTypeError, cli.read_file, relative_path)
test_contents = b'bar\n'
- with open(rel_test_path, 'wb') as f:
+ with open(relative_path, 'wb') as f:
f.write(test_contents)
- path, contents = cli.read_file(rel_test_path)
+ path, contents = cli.read_file(relative_path)
self.assertEqual(path, os.path.abspath(path))
self.assertEqual(contents, test_contents)
finally: