[Reproducible-commits] [debbindiff] 02/02: Set locale environment during tests

Jérémy Bobbio lunar at moszumanska.debian.org
Thu Jul 30 09:12:08 UTC 2015


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

lunar pushed a commit to branch master
in repository debbindiff.

commit eb5e260e7004653d6a7018ab9c3b74e8c9ceee0a
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Thu Jul 30 09:09:50 2015 +0000

    Set locale environment during tests
    
    Reset locale environment when running tests, just like
    we do when running the program. This ensure a consistant
    output from the tests even if systems are configured
    differently.
---
 debbindiff.py                 | 16 +---------------
 debbindiff/__init__.py        | 18 ++++++++++++++++++
 tests/comparators/conftest.py | 26 ++++++++++++++++++++++++++
 3 files changed, 45 insertions(+), 15 deletions(-)

diff --git a/debbindiff.py b/debbindiff.py
index 4c912e5..ff13f1f 100755
--- a/debbindiff.py
+++ b/debbindiff.py
@@ -27,7 +27,7 @@ import codecs
 import os
 import sys
 import traceback
-from debbindiff import logger, VERSION
+from debbindiff import logger, VERSION, set_locale
 import debbindiff.comparators
 from debbindiff.presenters.html import output_html
 from debbindiff.presenters.text import output_text
@@ -84,20 +84,6 @@ class ListToolsAction(argparse.Action):
         sys.exit(0)
 
 
-def set_locale():
-    """Normalize locale so external tool gives us stable and properly
-    encoded output"""
-
-    for var in ['LANGUAGE', 'LC_ALL']:
-        if var in os.environ:
-            del os.environ[var]
-    for var in ['LANG', 'LC_NUMERIC', 'LC_TIME', 'LC_COLLATE', 'LC_MONETARY',
-                'LC_MESSAGES', 'LC_PAPER', 'LC_NAME', 'LC_ADDRESS',
-                'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION']:
-        os.environ[var] = 'C'
-    os.environ['LC_CTYPE'] = 'C.UTF-8'
-
-
 def main():
     parser = create_parser()
     parsed_args = parser.parse_args(sys.argv[1:])
diff --git a/debbindiff/__init__.py b/debbindiff/__init__.py
index 5949954..6196a06 100644
--- a/debbindiff/__init__.py
+++ b/debbindiff/__init__.py
@@ -20,6 +20,7 @@
 from functools import wraps
 import logging
 from distutils.spawn import find_executable
+import os
 
 VERSION = "26"
 
@@ -91,3 +92,20 @@ def tool_required(command):
                 raise RequiredToolNotFound(command)
         return tool_check
     return wrapper
+
+
+def set_locale():
+    """Normalize locale so external tool gives us stable and properly
+    encoded output"""
+
+    for var in ['LANGUAGE', 'LC_ALL']:
+        if var in os.environ:
+            del os.environ[var]
+    for var in ['LANG', 'LC_NUMERIC', 'LC_TIME', 'LC_COLLATE', 'LC_MONETARY',
+                'LC_MESSAGES', 'LC_PAPER', 'LC_NAME', 'LC_ADDRESS',
+                'LC_TELEPHONE', 'LC_MEASUREMENT', 'LC_IDENTIFICATION']:
+        os.environ[var] = 'C'
+    os.environ['LC_CTYPE'] = 'C.UTF-8'
+
+
+
diff --git a/tests/comparators/conftest.py b/tests/comparators/conftest.py
new file mode 100644
index 0000000..224cebe
--- /dev/null
+++ b/tests/comparators/conftest.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# debbindiff: highlight differences between two builds of Debian packages
+#
+# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+#
+# debbindiff is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# debbindiff is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with debbindiff.  If not, see <http://www.gnu.org/licenses/>.
+
+import debbindiff
+import pytest
+
+ at pytest.fixture(autouse=True)
+def set_locale():
+    debbindiff.set_locale()    

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



More information about the Reproducible-commits mailing list