[Python-modules-commits] [python-jsontest] 01/04: import python-jsontest_1.2.orig.tar.gz

Daniel Stender stender at moszumanska.debian.org
Sat Jun 4 03:46:58 UTC 2016


This is an automated email from the git hooks/post-receive script.

stender pushed a commit to branch master
in repository python-jsontest.

commit 366491f6486011a979fe1e3610cbdeb65fdc8260
Author: Daniel Stender <stender at debian.org>
Date:   Sat Jun 4 05:40:45 2016 +0200

    import python-jsontest_1.2.orig.tar.gz
---
 .gitignore  |  4 ++++
 LICENSE.md  |  7 +++++++
 README.md   | 21 +++++++++++++++++++++
 jsontest.py | 26 ++++++++++++++++++++++++++
 release.sh  | 12 ++++++++++++
 setup.py    | 19 +++++++++++++++++++
 6 files changed, 89 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d1a27e0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.DS_Store
+*.pyc
+dist/
+*.egg-info
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..154b9f4
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,7 @@
+Copyright (C) 2015 Nick Barrett <pointlessrambler at gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..78a0114
--- /dev/null
+++ b/README.md
@@ -0,0 +1,21 @@
+# JsonTest
+
+`JsonTest` is a tiny metaclass designed for automatically generating tests based off JSON files. Originally built for testing [`ElasticQuery`](https://github.com/Fizzadar/ElasticQuery).
+
+## Synopsis
+
+```py
+from jsontest import JsonTest
+
+class MyTests(TestCase):
+    # Set the metaclass to JsonTest
+    __metaclass__ = JsonTest
+
+    # Tell JsonTest where to find our JSON files
+    jsontest_files = path.join('tests', 'filters')
+
+    # Define a function to run against each file
+    def jsontest_function(self, test_name, test_data):
+        print test_name, test_data
+        self.assertFalse(False)
+```
diff --git a/jsontest.py b/jsontest.py
new file mode 100644
index 0000000..4d27f68
--- /dev/null
+++ b/jsontest.py
@@ -0,0 +1,26 @@
+import json
+from os import listdir, path
+
+
+class JsonTest(type):
+    def __new__(cls, name, bases, attrs):
+        # Get the JSON files
+        files = listdir(attrs['jsontest_files'])
+        files = [f for f in files if f.endswith('.json')]
+
+        def gen_test(test_name, test_data):
+            def test(self):
+                self.jsontest_function(test_name, test_data)
+
+            return test
+
+        # Loop them and create class methods to call the jsontest_function
+        for filename in files:
+            test_name = filename[:-5]
+            test_data = json.loads(open(path.join(attrs['jsontest_files'], filename)).read())
+
+            # Attach the method
+            method_name = 'test_{0}'.format(test_name)
+            attrs[method_name] = gen_test(test_name, test_data)
+
+        return type.__new__(cls, name, bases, attrs)
diff --git a/release.sh b/release.sh
new file mode 100755
index 0000000..a8f2302
--- /dev/null
+++ b/release.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+VERSION=`python setup.py --version`
+
+echo "Doing git..."
+git tag -a v$VERSION -m v$VERSION
+git push --tags
+
+echo "Doing pypi..."
+python setup.py sdist upload
+
+echo "Done!"
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..2314537
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+# JsonTest
+# File: setup.py
+# Desc: needed
+
+try:
+    from setuptools import setup
+except ImportError:
+    from distutils.core import setup
+
+setup(
+    version='1.2',
+    name='JsonTest',
+    description='A tiny metaclass for autogenerating tests from JSON files',
+    author='Nick Barrett',
+    author_email='pointlessrambler at gmail.com',
+    url='http://github.com/Fizzadar/JsonTest',
+    py_modules=['jsontest']
+)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-jsontest.git



More information about the Python-modules-commits mailing list