[Reproducible-commits] [diffoscope] 02/02: Stop failing to run the tests when uid 1000 doesn't exist

Jérémy Bobbio lunar at moszumanska.debian.org
Sun Aug 9 06:28:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository diffoscope.

commit c8e9de4db76fe488142520117f8ee6a5d4f6c461
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Sun Aug 9 08:26:19 2015 +0200

    Stop failing to run the tests when uid 1000 doesn't exist
---
 tests/comparators/conftest.py      | 8 ++++++++
 tests/comparators/test_squashfs.py | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tests/comparators/conftest.py b/tests/comparators/conftest.py
index 267cb36..671be3c 100644
--- a/tests/comparators/conftest.py
+++ b/tests/comparators/conftest.py
@@ -29,3 +29,11 @@ def set_locale():
 
 def tool_missing(cmd):
     return find_executable(cmd) is None
+
+
+# from Jerry Kindall at http://stackoverflow.com/a/7088133
+def try_except(success, failure, *exceptions):
+    try:
+        return success()
+    except exceptions or Exception:
+        return failure() if callable(failure) else failure
diff --git a/tests/comparators/test_squashfs.py b/tests/comparators/test_squashfs.py
index 37372b8..bc85b9a 100644
--- a/tests/comparators/test_squashfs.py
+++ b/tests/comparators/test_squashfs.py
@@ -26,7 +26,7 @@ import pytest
 from diffoscope.comparators import specialize
 from diffoscope.comparators.binary import FilesystemFile
 from diffoscope.comparators.squashfs import SquashfsFile
-from conftest import tool_missing
+from conftest import tool_missing, try_except
 
 TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.squashfs')
 TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.squashfs')
@@ -61,7 +61,7 @@ def test_superblock(differences):
     assert differences[0].unified_diff == expected_diff
 
 # I know, the next line is pretty lame. But fixing #794096 would be the real fix for this.
- at pytest.mark.skipif(pwd.getpwuid(1000).pw_name != 'lunar', reason='uid 1000 is not lunar')
+ at pytest.mark.skipif(try_except(lambda: pwd.getpwuid(1000).pw_name != 'lunar', False, KeyError), reason='uid 1000 is not lunar')
 @pytest.mark.skipif(tool_missing('unsquashfs'), reason='missing unsquashfs')
 def test_listing(differences):
     expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/squashfs_listing_expected_diff')).read()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list