mirror of
https://github.com/django-components/django-components.git
synced 2025-08-04 06:18:17 +00:00
Merge pull request #1 from EmilStenstrom/ci
Setup Travis CI to test against both Python 2 and Python 3.
This commit is contained in:
commit
f35f2063ed
8 changed files with 51 additions and 23 deletions
10
.travis.yml
Normal file
10
.travis.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
sudo: false
|
||||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.4"
|
||||
install: pip install tox-travis
|
||||
script: tox
|
||||
branches:
|
||||
only:
|
||||
- master
|
|
@ -34,3 +34,12 @@ In your templates, use your component by first importing the django_components t
|
|||
{% component name="calendar" date=custom_date %}
|
||||
{% endblock %}
|
||||
```
|
||||
|
||||
# Running the tests
|
||||
|
||||
Install and run `tox`:
|
||||
|
||||
```sh
|
||||
pip install tox
|
||||
tox
|
||||
```
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Django>=1.5
|
|
@ -1,8 +0,0 @@
|
|||
import unittest
|
||||
|
||||
# Runs all tests found in filenames matching "test*""
|
||||
if __name__ == '__main__':
|
||||
test_loader = unittest.defaultTestLoader
|
||||
test_runner = unittest.TextTestRunner()
|
||||
test_suite = test_loader.discover('.')
|
||||
test_runner.run(test_suite)
|
12
setup.py
Normal file
12
setup.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='django-components',
|
||||
packages=find_packages(exclude='tests'),
|
||||
classifiers=[
|
||||
'Private :: Do Not Upload',
|
||||
],
|
||||
install_requires=[
|
||||
'Django>=1.5'
|
||||
],
|
||||
)
|
|
@ -4,6 +4,14 @@ import django
|
|||
from django.conf import settings
|
||||
from django_components import component
|
||||
|
||||
settings.configure(
|
||||
TEMPLATES=[{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': ["tests/templates/"],
|
||||
}]
|
||||
)
|
||||
django.setup()
|
||||
|
||||
class SimpleComponent(component.Component):
|
||||
def context(self, variable=None):
|
||||
return {
|
||||
|
@ -16,15 +24,6 @@ class SimpleComponent(component.Component):
|
|||
js = ("script.js",)
|
||||
|
||||
class ComponentRegistryTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
settings.configure(
|
||||
TEMPLATES=[{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': ["tests/templates/"],
|
||||
}]
|
||||
)
|
||||
django.setup()
|
||||
|
||||
def test_simple_component(self):
|
||||
comp = SimpleComponent()
|
||||
|
||||
|
|
|
@ -11,16 +11,16 @@ class ComponentRegistryTest(unittest.TestCase):
|
|||
def test_simple_register(self):
|
||||
self.registry.register(name="testcomponent", component=MockComponent)
|
||||
self.assertEqual(
|
||||
self.registry._registry.items(),
|
||||
[("testcomponent", MockComponent)]
|
||||
self.registry._registry,
|
||||
{"testcomponent": MockComponent}
|
||||
)
|
||||
|
||||
def test_register_two_components(self):
|
||||
self.registry.register(name="testcomponent", component=MockComponent)
|
||||
self.registry.register(name="testcomponent2", component=MockComponent)
|
||||
self.assertEqual(
|
||||
self.registry._registry.items(),
|
||||
[("testcomponent", MockComponent), ("testcomponent2", MockComponent)]
|
||||
self.registry._registry,
|
||||
{"testcomponent": MockComponent, "testcomponent2": MockComponent}
|
||||
)
|
||||
|
||||
def test_prevent_registering_twice(self):
|
||||
|
@ -31,7 +31,7 @@ class ComponentRegistryTest(unittest.TestCase):
|
|||
def test_simple_unregister(self):
|
||||
self.registry.register(name="testcomponent", component=MockComponent)
|
||||
self.registry.unregister(name="testcomponent")
|
||||
self.assertEqual(self.registry._registry.items(), [])
|
||||
self.assertEqual(self.registry._registry, {})
|
||||
|
||||
def test_raises_on_failed_unregister(self):
|
||||
with self.assertRaises(component.NotRegistered):
|
||||
|
|
7
tox.ini
Normal file
7
tox.ini
Normal file
|
@ -0,0 +1,7 @@
|
|||
[tox]
|
||||
envlist = py27, py34
|
||||
|
||||
[testenv]
|
||||
deps =
|
||||
pytest
|
||||
commands = py.test {posargs}
|
Loading…
Add table
Add a link
Reference in a new issue