Skip to content

Commit

Permalink
Merge pull request #49 from clarkduvall/py26
Browse files Browse the repository at this point in the history
Remove Python 2.6 support
  • Loading branch information
clarkduvall authored Sep 29, 2017
2 parents 34dae3e + 08c0090 commit 4b38d30
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ python:
- 3.4
- 3.3
- 2.7
- 2.6
- pypy
install:
- pip install -r requirements.txt
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
Expand Down
27 changes: 15 additions & 12 deletions tests/test_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class ASerializer(Serializer):

o = Obj(a=None)
data = ASerializer(o).data
self.assertFalse('a' in data)
self.assertNotIn('a', data)

o = Obj(a='5')
data = ASerializer(o).data
Expand All @@ -168,7 +168,8 @@ class ASerializer(Serializer):
a = IntField()

o = Obj(a=None)
self.assertRaises(TypeError, lambda: ASerializer(o).data)
with self.assertRaises(TypeError):
ASerializer(o).data

def test_optional_methodfield(self):
class ASerializer(Serializer):
Expand All @@ -179,7 +180,7 @@ def get_a(self, obj):

o = Obj(a=None)
data = ASerializer(o).data
self.assertFalse('a' in data)
self.assertNotIn('a', data)

o = Obj(a='5')
data = ASerializer(o).data
Expand All @@ -192,26 +193,28 @@ def get_a(self, obj):
return obj.a

o = Obj(a=None)
self.assertRaises(TypeError, lambda: ASerializer(o).data)
with self.assertRaises(TypeError):
ASerializer(o).data

def test_error_on_data(self):
self.assertRaises(RuntimeError, lambda: Serializer(data='foo'))
with self.assertRaises(RuntimeError):
Serializer(data='foo')

def test_serializer_with_custom_output_label(self):
class ASerializer(Serializer):
context = StrField(label="@context")
content = MethodField(label="@content")
context = StrField(label='@context')
content = MethodField(label='@content')

def get_content(self, obj):
return obj.content

o = Obj(context="http://foo/bar/baz/", content="http://baz/bar/foo/")
o = Obj(context='http://foo/bar/baz/', content='http://baz/bar/foo/')
data = ASerializer(o).data

self.assertTrue("@context" in data)
self.assertEqual(data["@context"], "http://foo/bar/baz/")
self.assertTrue("@content" in data)
self.assertEqual(data["@content"], "http://baz/bar/foo/")
self.assertIn('@context', data)
self.assertEqual(data['@context'], 'http://foo/bar/baz/')
self.assertIn('@content', data)
self.assertEqual(data['@content'], 'http://baz/bar/foo/')


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py26, py27, py32, py33, py34, py35, py36, pypy
envlist = py27, py32, py33, py34, py35, py36, pypy

[testenv]
commands = {envpython} setup.py test
Expand Down

0 comments on commit 4b38d30

Please sign in to comment.