Commit 18c67ff1 authored by godog's avatar godog
Browse files

test: port to Python 3

parent 7c616571
Pipeline #6937 passed with stage
in 59 seconds
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
WORKDIR /config
RUN python setup.py install
RUN python3 setup.py install
ENV TEST_CONFIG=/test-config.yml
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
installare alcuni prerequisiti. Anzitutto serve *virtualenv*, per
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
locale di Python (per evitare di "sporcare" il sistema con le
dipendenze della suite di test):
$ virtualenv venv
$ virtualenv --python python3 venv
Infine bisogna installare la test suite dentro questo ambiente Python
temporaneo:
$ ./venv/bin/python setup.py develop
$ ./venv/bin/python3 setup.py develop
# Test
......@@ -33,4 +33,4 @@ esempio, per testare l'ambiente locale Vagrant di default:
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
......@@ -16,7 +16,7 @@ class WebUsersBase(TestBase):
endpoint, ANSIBLE_VARS['domain_public'][0], path)
handlers = []
if username and password:
h = urllib2.HTTPBasicAuthHandler()
h = urllib.request.HTTPBasicAuthHandler()
h.add_password('', '/', username, password)
handlers.append(h)
result = request(url, self.frontend_ip(), handlers=handlers)
......@@ -48,4 +48,4 @@ class SubsiteTest(WebUsersBase):
url = 'https://www.%s/%s' % (
ANSIBLE_VARS['domain_public'][0], username)
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
setup(
......
[tox]
envlist = py27
envlist = py3
[testenv]
passenv = TEST_CONFIG
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment