Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows unittests and color output #284

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pyresttest/resttest.py
Original file line number Diff line number Diff line change
@@ -856,6 +856,16 @@ def main(args):

if 'skip_term_colors' in args and args['skip_term_colors'] is not None:
t.config.skip_term_colors = safe_to_bool(args['skip_term_colors'])
if not t.config.skip_term_colors:
try:
from colorama import init as colorama_init
except ImportError:
if sys.platform == 'win32':
logger.warn('Terminal colors on Windows require the colorama package. '
'`pip install colorama` to enable. Colors will be disabled.')
t.config.skip_term_colors = True
else: # run colorama_init() only if the import was successful
colorama_init()

# Execute all testsets
failures = run_testsets(tests)
8 changes: 4 additions & 4 deletions pyresttest/test_contenthandling.py
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@ def test_parse_content_file(self):
""" Test parsing of file content """
node = {'file': '/myval'}
handler = ContentHandler.parse_content(node)
self.assertEqual(node['file'], handler.content)
self.assertEqual(os.path.abspath(node['file']), handler.content)
self.assertFalse(handler.is_dynamic())
self.assertTrue(handler.is_file)
self.assertFalse(handler.is_template_path)
@@ -169,7 +169,7 @@ def test_parse_content_templated_file_path(self):
""" Test parsing of templated file path """
node = {'file': {'template': '/$host-path.yaml'}}
handler = ContentHandler.parse_content(node)
self.assertEqual('/$host-path.yaml', handler.content)
self.assertEqual(os.path.abspath('/$host-path.yaml'), handler.content)
self.assertTrue(handler.is_dynamic())
self.assertTrue(handler.is_file)
self.assertTrue(handler.is_template_path)
@@ -179,7 +179,7 @@ def test_parse_content_templated_file_content(self):
""" Test parsing of templated file content """
node = {'template': {'file': '/path.yaml'}}
handler = ContentHandler.parse_content(node)
self.assertEqual('/path.yaml', handler.content)
self.assertEqual(os.path.abspath('/path.yaml'), handler.content)
self.assertTrue(handler.is_dynamic())
self.assertTrue(handler.is_file)
self.assertFalse(handler.is_template_path)
@@ -189,7 +189,7 @@ def test_parse_content_double_templated_file(self):
""" Test parsing of file with path and content templated """
node = {'template': {'file': {'template': '/$var-path.yaml'}}}
handler = ContentHandler.parse_content(node)
self.assertEqual('/$var-path.yaml', handler.content)
self.assertEqual(os.path.abspath('/$var-path.yaml'), handler.content)
self.assertTrue(handler.is_dynamic())
self.assertTrue(handler.is_file)
self.assertTrue(handler.is_template_path)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
from distutils.core import setup

# Future is needed for pip distribution for python 3 support
dependencies = ['pyyaml', 'pycurl']
dependencies = ['pyyaml', 'pycurl', 'colorama;platform_system=="Windows"']
test_dependencies = ['django==1.6.5','django-tastypie==0.12.1','jsonpath','jmespath']

# Add additional compatibility shims