Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sissaschool/xmlschema
Browse files Browse the repository at this point in the history
  • Loading branch information
brunato committed May 28, 2020
2 parents d463c8e + 53719c1 commit b615215
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ matrix:
- pip3 install --upgrade pip
install: pip3 install -r requirements-dev.txt
script: python3 tests/test_all.py
- name: "Python 3.7.7 on macOS 10.14.6"
os: osx
osx_image: xcode11.3
language: shell
before_install:
- python3 --version
- pip3 install --upgrade pip
install: pip3 install -r requirements-dev.txt
script: python3 tests/test_all.py
- name: "Python 3.7.7 on macOS 10.15.4"
os: osx
osx_image: xcode11.4
language: shell
before_install:
- python3 --version
- pip3 install --upgrade pip
install: pip3 install -r requirements-dev.txt
script: python3 tests/test_all.py
- name: "Python 3.7.4 on Windows"
os: windows
language: shell
Expand Down
18 changes: 12 additions & 6 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io
import pathlib
import os
import platform
import sys

from xmlschema.cli import validate, xml2json, json2xml
Expand Down Expand Up @@ -77,19 +78,24 @@ def test_validate_command_03(self, mock_out, mock_err):
def test_validate_command_04(self, mock_out, mock_err):
self.run_validate('unknown.xml')
self.assertEqual(mock_err.getvalue(), '')
self.assertIn("No such file or directory", mock_out.getvalue())
output = mock_out.getvalue()
if platform.system() == 'Windows':
self.assertIn("The system cannot find the file specified", output)
else:
self.assertIn("No such file or directory", output)
self.assertEqual('1', str(self.ctx.exception))

@patch('sys.stderr', new_callable=io.StringIO)
@patch('sys.stdout', new_callable=io.StringIO)
def test_validate_command_05(self, mock_out, mock_err):
self.run_validate(*glob.glob('vehicles*.xml'))
self.assertEqual(mock_err.getvalue(), '')
self.assertEqual("vehicles.xml is valid\n"
"vehicles-3_errors.xml is not valid\n"
"vehicles-1_error.xml is not valid\n"
"vehicles2.xml is valid\n"
"vehicles-2_errors.xml is not valid\n", mock_out.getvalue())
output = mock_out.getvalue()
self.assertIn("vehicles.xml is valid", output)
self.assertIn("vehicles-3_errors.xml is not valid", output)
self.assertIn("vehicles-1_error.xml is not valid", output)
self.assertIn("vehicles2.xml is valid", output)
self.assertIn("vehicles-2_errors.xml is not valid", output)
self.assertEqual('6', str(self.ctx.exception))

@patch('sys.stderr', new_callable=io.StringIO)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def test_xml_resource_access(self):

with self.assertRaises(XMLSchemaResourceError) as ctx:
XMLResource("/tmp/vehicles.xsd", base_url=base_url, allow='sandbox')
self.assertEqual(str(ctx.exception),
self.assertEqual(str(ctx.exception).replace('\\', '/'),
"block access to out of sandbox file /tmp/vehicles.xsd")

with self.assertRaises(TypeError) as ctx:
Expand Down

0 comments on commit b615215

Please sign in to comment.