From c57a62c7c0266f9cdf1d916fdf9e09da10f58173 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Mon, 26 Aug 2013 01:00:06 +0100 Subject: [PATCH 1/3] Fix dict dump test --- setup.py | 8 ++++++++ tests.py | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 49f17af..7ad4a8b 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,13 @@ import os from setuptools import setup +try: + from collections import OrderedDict # noqa + requirements = [] +except ImportError: + requirements = ['ordereddict'] + + def get_docs(): result = [] in_docs = False @@ -29,6 +36,7 @@ def get_docs(): long_description=get_docs(), zip_safe=False, test_suite='tests', + install_requires=requirements, classifiers=[ 'License :: OSI Approved :: BSD License', 'Programming Language :: PHP', diff --git a/tests.py b/tests.py index f6d7066..7ee1ba2 100644 --- a/tests.py +++ b/tests.py @@ -1,5 +1,11 @@ # -*- coding: utf-8 -*- import unittest + +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict + import phpserialize @@ -32,8 +38,9 @@ def test_dumps_tuple(self): b'a:3:{i:0;i:7;i:1;i:8;i:2;i:9;}') def test_dumps_dict(self): - self.assertEqual(phpserialize.dumps({'a': 1, 'b': 2, 'c': 3}), - b'a:3:{s:1:"a";i:1;s:1:"c";i:3;s:1:"b";i:2;}') + self.assertEqual( + phpserialize.dumps(OrderedDict([('a', 1), ('b', 2), ('c', 3)])), + b'a:3:{s:1:"a";i:1;s:1:"b";i:2;s:1:"c";i:3;}') def test_loads_dict(self): self.assertEqual(phpserialize.loads(b'a:3:{s:1:"a";i:1;s:1:"c";i:3;s:1:"b";i:2;}', From 1a78ea9de21114f4731655cc8abfeced2f9522a4 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Mon, 26 Aug 2013 01:00:31 +0100 Subject: [PATCH 2/3] Refactor one test --- tests.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests.py b/tests.py index 7ee1ba2..89a9e92 100644 --- a/tests.py +++ b/tests.py @@ -55,8 +55,9 @@ def test_loads_binary(self): b'\001\002\003') def test_dumps_and_loads_dict(self): - self.assertEqual(phpserialize.loads(phpserialize.dumps({'a': 1, 'b': 2, 'c': 3}), - decode_strings=True), {'a': 1, 'b': 2, 'c': 3}) + payload = {'a': 1, 'b': 2, 'c': 3} + self.assertEqual(phpserialize.loads(phpserialize.dumps(payload), + decode_strings=True), payload) def test_list_roundtrips(self): x = phpserialize.loads(phpserialize.dumps(list(range(2)))) From f2c2b380a8cea92fcd8aa894f45c945e3d9828bb Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Mon, 26 Aug 2013 01:01:29 +0100 Subject: [PATCH 3/3] Add Travis configuration --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..502550c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: python +python: + - "2.6" + - "2.7" + - "3.2" + - "3.3" + - "pypy" +install: python setup.py install +script: python tests.py