summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildout.cfg3
-rw-r--r--src/mailman/app/docs/hooks.txt4
-rw-r--r--src/mailman/testing/layers.py15
3 files changed, 19 insertions, 3 deletions
diff --git a/buildout.cfg b/buildout.cfg
index 6b31c0310..5c4d1226c 100644
--- a/buildout.cfg
+++ b/buildout.cfg
@@ -26,7 +26,8 @@ eggs =
defaults = '--tests-pattern ^tests --exit-with-status'.split()
# Hack in extra arguments to zope.testrunner.
initialization = from mailman.testing.layers import ConfigLayer;
- ConfigLayer.enable_stderr()
+ ConfigLayer.enable_stderr();
+ ConfigLayer.set_root_directory('${buildout:directory}')
[docs]
recipe = z3c.recipe.sphinxdoc
diff --git a/src/mailman/app/docs/hooks.txt b/src/mailman/app/docs/hooks.txt
index e5b3f1ae1..efd5530f5 100644
--- a/src/mailman/app/docs/hooks.txt
+++ b/src/mailman/app/docs/hooks.txt
@@ -48,11 +48,11 @@ we can't run those initialization steps in process, so call a command line
script that will produce no output to force the hooks to run.
>>> import subprocess
+ >>> from mailman.testing.layers import ConfigLayer
>>> def call():
... proc = subprocess.Popen(
... 'bin/mailman lists --domain ignore -q'.split(),
- ... # testrunner runs from ./parts/test/working-directory
- ... cwd='../../..',
+ ... cwd=ConfigLayer.root_directory,
... env=dict(MAILMAN_CONFIG_FILE=config_path,
... PYTHONPATH=config_directory),
... stdout=subprocess.PIPE, stderr=subprocess.PIPE)
diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py
index 34dc46807..8f16d5940 100644
--- a/src/mailman/testing/layers.py
+++ b/src/mailman/testing/layers.py
@@ -217,6 +217,21 @@ class ConfigLayer(MockAndMonkeyLayer):
if len(os.environ.get('MM_VERBOSE_TESTLOG', '').strip()) > 0:
cls.stderr = True
+ # The top of our source tree, for tests that care (e.g. hooks.txt).
+ root_directory = None
+
+ @classmethod
+ def set_root_directory(cls, directory):
+ """Set the directory at the root of our source tree.
+
+ zc.recipe.testrunner runs from parts/test/working-directory, but
+ that's actually changed over the life of the package. Some tests
+ care, e.g. because they need to find our built-out bin directory.
+ Fortunately, buildout can give us this information. See the
+ `buildout.cfg` file for where this method is called.
+ """
+ cls.root_directory = directory
+
class SMTPLayer(ConfigLayer):