Skip to content

Commit

Permalink
use "@expect_failure" decorator for testing features which are not ye…
Browse files Browse the repository at this point in the history
…t implemented

This means we need PythonicTestcase >= 1.3.0. The decorator is preferrable
to "skipTest()" because it prevents bit-rotting of the test code (e.g.
due to API changes).
  • Loading branch information
FelixSchwarz committed Jan 23, 2016
1 parent 00e0b05 commit 9dd3d58
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ argparse
httplib2>=0.7.0
jinja2
lxml
pythonic_testcase
PythonicTestcase >= 1.3.0
six>=1.5.2
3 changes: 1 addition & 2 deletions tests/django_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# Django 1.8 does not support Python 2.6 anymore, importing the module
# triggers a SyntaxError which causes builds to fail.
django = None
from nose import SkipTest
from pythonic_testcase import *

from soapfish.django_ import django_dispatcher
Expand All @@ -27,7 +26,7 @@
class DjangoDispatchTest(PythonicTestCase):
def setUp(self):
if django is None:
raise SkipTest('django not installed')
self.skipTest('django not installed')
super(DjangoDispatchTest, self).setUp()
self.service = echo_service()
if django.conf.settings.__dict__['_wrapped'] is empty:
Expand Down
2 changes: 1 addition & 1 deletion tests/flask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def setUp(self):
try:
from flask import Flask
except ImportError:
raise self.skipTest('flask not installed')
self.skipTest('flask not installed')

super(FlaskDispatchTest, self).setUp()
self.service = echo_service()
Expand Down
6 changes: 3 additions & 3 deletions tests/wsdl_code_generation_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function

from nose import SkipTest
from pythonic_testcase import *

from soapfish import xsd
Expand All @@ -9,8 +8,8 @@


class XSDCodeGenerationTest(PythonicTestCase):
@expect_failure
def test_can_generate_code_for_two_schemas(self):
raise SkipTest('can not generate code for wsdl with multiple schemas')
xml = '<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:b="http://example.org/B">'\
' <wsdl:types>'\
' <xsd:schema elementFormDefault="qualified" targetNamespace="http://example.org/A">' \
Expand All @@ -30,8 +29,9 @@ def test_can_generate_code_for_two_schemas(self):

assert_equals(['B', 'A'], list(schema.elements))

@expect_failure
def test_can_generate_code_for_inheritance(self):
raise SkipTest('can not generate code for wsdl with type inheritance')
# can not generate code for wsdl with type inheritance
xml = '<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' \
' <wsdl:types>' \
' <xsd:schema elementFormDefault="qualified" targetNamespace="http://example.org/A">' \
Expand Down
5 changes: 2 additions & 3 deletions tests/xsd/xsd_ref_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

from nose import SkipTest
from pythonic_testcase import *

from soapfish import xsd
Expand All @@ -22,9 +21,9 @@ class Job(xsd.ComplexType):
b' <name>Foo Bar</name>\n'
b'</job>\n')
assert_equals(expected_xml, job.xml('job'))


@expect_failure
def test_can_render_references_to_simple_types(self):
raise SkipTest('References to SimpleTypes are not yet implemented.')
class Person(xsd.SimpleType):
pass

Expand Down
17 changes: 10 additions & 7 deletions tests/xsd_code_generation_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import print_function

from lxml import etree
from nose import SkipTest
from pythonic_testcase import *

from soapfish import xsd, xsdspec
Expand All @@ -27,9 +26,10 @@ def test_can_generate_code_for_simple_element(self):
assert_equals(['simpleElement'], list(schema.elements))
simple_element = schema.elements['simpleElement']
assert_isinstance(simple_element._type, xsd.String)


@expect_failure
def test_can_generate_code_with_xsd_refs_to_simple_elements(self):
raise SkipTest('References to simple elements not yet implemented')
# References to simple elements are not yet implemented
xml = ('<xs:schema targetNamespace="http://site.example/ws/spec" \n'
' xmlns:example="http://site.example/ws/spec" \n'
' xmlns:xs="http://www.w3.org/2001/XMLSchema" \n'
Expand Down Expand Up @@ -68,9 +68,10 @@ def test_can_generate_code_with_xsd_refs_to_simple_elements(self):
# Should not raise
job.name = u'Foo'
# probably we need to check some more stuff here


@expect_failure
def test_can_generate_code_with_xsd_refs_to_elements_with_anoynmous_complex_types(self):
raise SkipTest('References to elements with anonymous complex types are not yet implemented')
# References to elements with anonymous complex types are not yet implemented
# The final test should have an object graph representation of the
# schema below. Currently I don't know how to represent multiple
# xs:elements in a schema without using ComplexTypes.
Expand Down Expand Up @@ -130,8 +131,9 @@ def test_implicit_target_namespace(self):
xsd2py.schema_to_py(generated_schema, ['xs'],
parent_namespace="http://site.example/ws/spec")

@expect_failure
def test_can_generate_list_enumeration(self):
raise SkipTest('list enumerations are not parsed correctly from xsd')
# list enumerations are not parsed correctly from xsd
xml = '<xsd:schema elementFormDefault="qualified" targetNamespace="http://example.org/A" xmlns:xsd="http://www.w3.org/2001/XMLSchema">' \
' <xsd:simpleType name="MyList">' \
' <xsd:list>' \
Expand All @@ -157,8 +159,9 @@ def test_can_generate_list_enumeration(self):
my_list = new_symbols['MyList']()
assert_equals(my_list.accept(['B']), True)

@expect_failure
def test_can_generate_extension(self):
raise SkipTest('extension subclass fails with lazy defined base')
# extension subclass fails with lazy defined base
xml = """
<xs:schema targetNamespace="http://example.com"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
Expand Down
4 changes: 2 additions & 2 deletions tests/xsd_types/xsddate_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-

from nose import SkipTest
from pythonic_testcase import *

from soapfish.xsd_types import XSDDate
Expand All @@ -16,8 +15,9 @@ def test_raises_exception_when_instantiating_invalid_dates(self):
assert_raises(ValueError, lambda: XSDDate(2014, 13, 10))
assert_raises(ValueError, lambda: XSDDate(2011, 2, 29))

@expect_failure
def test_supports_very_distant_dates(self):
raise SkipTest('XSDDate can currently only represent the value range of datetime.date')
# XSDDate can currently only represent the value range of datetime.date
future = XSDDate(12345, 4, 21)
assert_equals(12345, future.year)

Expand Down
6 changes: 3 additions & 3 deletions tests/xsdspec_element_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

from nose import SkipTest
from pythonic_testcase import *

from soapfish import xsd, xsdspec
Expand Down Expand Up @@ -31,9 +30,10 @@ def test_can_render_elements_with_anonymous_simple_types(self):
b' </simpleType>\n'
b'</element>\n')
assert_equals(expected_xml, element.xml('element'))


@expect_failure
def test_element_with_ref_attribute_rejects_forbidden_attributes(self):
raise SkipTest('Elements with "ref" attribute currently do not restrict setting other attributes.')
# Elements with "ref" attribute currently do not restrict setting other attributes.
element = xsdspec.Element()
element.ref = 'foo'
element.minOccurs = 3
Expand Down

0 comments on commit 9dd3d58

Please sign in to comment.