Skip to content

Commit 7735717

Browse files
committed
tests: fix bounce test paths to be __file__-relative
Previously used CWD-relative paths which only worked when testall.py was invoked from the prefix root (e.g. python3 tests/testall.py). Using __file__-relative paths works regardless of invocation directory.
1 parent bc0f823 commit 7735717

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/test_bounces.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import os
2222
import unittest
2323
import email
24+
25+
_TESTDIR = os.path.dirname(os.path.abspath(__file__))
2426
try:
2527
from Mailman import __init__
2628
except ImportError:
@@ -192,7 +194,7 @@ def test_bounce(self):
192194
for modname, file, addrs in self.DATA:
193195
module = 'Mailman.Bouncers.' + modname
194196
__import__(module)
195-
fp = open(os.path.join('bounces', file))
197+
fp = open(os.path.join(_TESTDIR, 'bounces', file))
196198
try:
197199
msg = email.message_from_file(fp)
198200
finally:
@@ -212,7 +214,7 @@ def test_bounce(self):
212214
def test_SMTP32_failure(self):
213215
from Mailman.Bouncers import SMTP32
214216
# This file has no X-Mailer: header
215-
fp = open(os.path.join('bounces', 'postfix_01.txt'))
217+
fp = open(os.path.join(_TESTDIR, 'bounces', 'postfix_01.txt'))
216218
try:
217219
msg = email.message_from_file(fp)
218220
finally:

0 commit comments

Comments
 (0)