From c93f42fa9aa882ea8f6ac818d88f745bbc37ea04 Mon Sep 17 00:00:00 2001 From: Laura Liberda Date: Sun, 29 Nov 2020 05:00:23 +0100 Subject: [PATCH] py2.7c: test fxckers for basic py2.7 compatibility --- librefi/fxckers/__init__.py | 3 +++ tests/py2_compat.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/py2_compat.py diff --git a/librefi/fxckers/__init__.py b/librefi/fxckers/__init__.py index d642f2d..2a98d9c 100644 --- a/librefi/fxckers/__init__.py +++ b/librefi/fxckers/__init__.py @@ -1,3 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + from ._map import fxckers_map __all__ = ['fxckers_map'] diff --git a/tests/py2_compat.py b/tests/py2_compat.py new file mode 100644 index 0000000..dd8f18a --- /dev/null +++ b/tests/py2_compat.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from os import listdir, path +import re + + +def test_fxcker_files_py2_compatibility(): + dir = path.join('.', 'librefi', 'fxckers') + fxckers = listdir(dir) + for fxcker in fxckers: + if re.match(r'^\w+\.py$', fxcker): + with open(path.join(dir, fxcker), 'r') as file: + content = file.read() + if re.match(r'^(#!.+\r?\n)?\s*(# (-\*- )?coding: utf-8( -\*-)?\r?\n)?\s*(from __future__ import (\w+, )*unicode_literals)', + content) is None: + print(content) + print(fxcker) + raise AssertionError('fxcker %s not containing required compat imports' % (fxcker))