Skip to content
Snippets Groups Projects
Commit 18c67ff1 authored by godog's avatar godog
Browse files

test: port to Python 3

parent 7c616571
No related branches found
No related tags found
1 merge request!72test: port to Python 3
Pipeline #6937 passed
FROM registry.git.autistici.org/ai3/float:integration-test FROM registry.git.autistici.org/ai3/float:integration-test
RUN apt-get -q update && env DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends -y python python-pip python-setuptools python-yaml python-nose
ADD . /config ADD . /config
WORKDIR /config WORKDIR /config
RUN python setup.py install RUN python3 setup.py install
ENV TEST_CONFIG=/test-config.yml ENV TEST_CONFIG=/test-config.yml
ENV PYTHONPATH=/src ENV PYTHONPATH=/src
CMD ["nosetests", "-v", "ai3test"] CMD ["nosetests3", "-v", "ai3test"]
...@@ -7,18 +7,18 @@ Per testare l'ambiente locale di test di ai3 (Vagrant), bisogna prima ...@@ -7,18 +7,18 @@ Per testare l'ambiente locale di test di ai3 (Vagrant), bisogna prima
installare alcuni prerequisiti. Anzitutto serve *virtualenv*, per installare alcuni prerequisiti. Anzitutto serve *virtualenv*, per
es. su una macchina Debian: es. su una macchina Debian:
$ sudo apt-get install python-virtualenv $ sudo apt install python3-virtualenv
Dopodiché bisogna creare una directory *venv* con un'installazione Dopodiché bisogna creare una directory *venv* con un'installazione
locale di Python (per evitare di "sporcare" il sistema con le locale di Python (per evitare di "sporcare" il sistema con le
dipendenze della suite di test): dipendenze della suite di test):
$ virtualenv venv $ virtualenv --python python3 venv
Infine bisogna installare la test suite dentro questo ambiente Python Infine bisogna installare la test suite dentro questo ambiente Python
temporaneo: temporaneo:
$ ./venv/bin/python setup.py develop $ ./venv/bin/python3 setup.py develop
# Test # Test
...@@ -33,4 +33,4 @@ esempio, per testare l'ambiente locale Vagrant di default: ...@@ -33,4 +33,4 @@ esempio, per testare l'ambiente locale Vagrant di default:
L'integrazione con 'float' avviene tramite un playbook apposito (ai3-test): L'integrazione con 'float' avviene tramite un playbook apposito (ai3-test):
$ ANSIBLE_STDOUT_CALLBACK=minimal ../../float/float run ../../rules/playbooks/ai3-test.yml $ ANSIBLE_STDOUT_CALLBACK=minimal ../../float/float run ../../config/playbooks/ai3-test.yml
import urllib2 import urllib.request, urllib.error, urllib.parse
from ai3test import AI3_TEST_PARAMS, ANSIBLE_VARS, TestBase, request from ai3test import AI3_TEST_PARAMS, ANSIBLE_VARS, TestBase, request
...@@ -16,7 +16,7 @@ class WebUsersBase(TestBase): ...@@ -16,7 +16,7 @@ class WebUsersBase(TestBase):
endpoint, ANSIBLE_VARS['domain_public'][0], path) endpoint, ANSIBLE_VARS['domain_public'][0], path)
handlers = [] handlers = []
if username and password: if username and password:
h = urllib2.HTTPBasicAuthHandler() h = urllib.request.HTTPBasicAuthHandler()
h.add_password('', '/', username, password) h.add_password('', '/', username, password)
handlers.append(h) handlers.append(h)
result = request(url, self.frontend_ip(), handlers=handlers) result = request(url, self.frontend_ip(), handlers=handlers)
...@@ -48,4 +48,4 @@ class SubsiteTest(WebUsersBase): ...@@ -48,4 +48,4 @@ class SubsiteTest(WebUsersBase):
url = 'https://www.%s/%s' % ( url = 'https://www.%s/%s' % (
ANSIBLE_VARS['domain_public'][0], username) ANSIBLE_VARS['domain_public'][0], username)
result = request(url, self.frontend_ip()) result = request(url, self.frontend_ip())
self.assertEquals(result['location'], url + '/') self.assertEqual(result['location'], url + '/')
#!/usr/bin/python
from setuptools import setup, find_packages from setuptools import setup, find_packages
setup( setup(
......
[tox] [tox]
envlist = py27 envlist = py3
[testenv] [testenv]
passenv = TEST_CONFIG passenv = TEST_CONFIG
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment