Skip to content

Commit 36e3d4d

Browse files
committed
Test NGINX dynamic load module
1 parent eb01d48 commit 36e3d4d

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ python:
44
install: pip install -U tox-travis
55
script: tox
66
dist: xenial
7+
sudo: required
78
deploy:
89
provider: pypi
910
distributions: sdist

tests/test_nginxpy.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,28 @@
33

44
"""Tests for `nginxpy` package."""
55

6-
7-
import os
6+
import re
7+
import subprocess
8+
import tempfile
89
import unittest
10+
from os.path import exists, abspath
911

1012
import nginx
1113

14+
CONF_OK = re.compile(r'configuration file ([^ ]+) test is successful')
15+
1216

1317
class TestNginxpy(unittest.TestCase):
1418
def test_extension(self):
1519
self.assertTrue(hasattr(nginx, 'spec'))
16-
self.assertTrue(os.path.exists(nginx.spec.origin))
20+
self.assertTrue(exists(nginx.spec.origin))
21+
22+
with tempfile.NamedTemporaryFile('w') as f:
23+
f.write('error_log stderr;pid ')
24+
with tempfile.NamedTemporaryFile() as pid:
25+
f.write(abspath(pid.name))
26+
f.write(';load_module ')
27+
f.write(nginx.spec.origin)
28+
f.write(';events {}')
29+
f.flush()
30+
subprocess.check_call(['nginx', '-c', abspath(f.name), '-t'])

0 commit comments

Comments
 (0)