diff --git a/alfred-workflow-1.37.zip b/alfred-workflow-1.37.1.zip similarity index 81% rename from alfred-workflow-1.37.zip rename to alfred-workflow-1.37.1.zip index b18da405..eef43a54 100644 Binary files a/alfred-workflow-1.37.zip and b/alfred-workflow-1.37.1.zip differ diff --git a/tests/conftest.py b/tests/conftest.py index 857f3c80..be978224 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -102,6 +102,10 @@ def env(**kwargs): if k in os.environ: del os.environ[k] else: + if isinstance(v, unicode): + v = v.encode('utf-8') + else: + v = str(v) os.environ[k] = v yield diff --git a/tests/test_workflow.py b/tests/test_workflow.py index d543cc5d..626fa667 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -22,6 +22,8 @@ from workflow import Workflow +from .conftest import env + def test_args(alfred4): """ARGV""" @@ -106,5 +108,18 @@ def test_icons(): assert os.path.exists(path) +def test_debugging(alfred4): + """Debugging""" + tests = [ + ('', False), + ('0', False), + ('1', True), + ] + for s, wanted in tests: + with env(alfred_debug=s): + wf = Workflow() + assert wf.debugging == wanted, "unexpected debugging" + + if __name__ == '__main__': # pragma: no cover pytest.main([__file__]) diff --git a/workflow/version b/workflow/version index 71437d03..a537514b 100644 --- a/workflow/version +++ b/workflow/version @@ -1 +1 @@ -1.37 \ No newline at end of file +1.37.1 \ No newline at end of file diff --git a/workflow/workflow.py b/workflow/workflow.py index 584f376e..2a057b0b 100644 --- a/workflow/workflow.py +++ b/workflow/workflow.py @@ -1052,31 +1052,30 @@ def alfred_env(self): data = {} for key in ( - 'alfred_debug', - 'alfred_preferences', - 'alfred_preferences_localhash', - 'alfred_theme', - 'alfred_theme_background', - 'alfred_theme_subtext', - 'alfred_version', - 'alfred_version_build', - 'alfred_workflow_bundleid', - 'alfred_workflow_cache', - 'alfred_workflow_data', - 'alfred_workflow_name', - 'alfred_workflow_uid', - 'alfred_workflow_version'): - - value = os.getenv(key) - - if isinstance(value, str): - if key in ('alfred_debug', 'alfred_version_build', - 'alfred_theme_subtext'): + 'debug', + 'preferences', + 'preferences_localhash', + 'theme', + 'theme_background', + 'theme_subtext', + 'version', + 'version_build', + 'workflow_bundleid', + 'workflow_cache', + 'workflow_data', + 'workflow_name', + 'workflow_uid', + 'workflow_version'): + + value = os.getenv('alfred_' + key, '') + + if value: + if key in ('debug', 'version_build', 'theme_subtext'): value = int(value) else: value = self.decode(value) - data[key[7:]] = value + data[key] = value self._alfred_env = data @@ -1113,7 +1112,7 @@ def debugging(self): :rtype: ``bool`` """ - return self.alfred_env.get('debug') == '1' + return self.alfred_env.get('debug') == 1 @property def name(self):