Closed ale-rt closed 4 years ago
I have this file (see bottom of the issue) with two tests that use the MOCK_MAILHOST_FIXTURE as stated in the documentation:
MOCK_MAILHOST_FIXTURE
If now I run:
./bin/test -t TestCase1 -t TestCase2
or
./bin/test -t TestCase2 -t TestCase1
The test_mailhost2 is failing because the portal mailhost is not the fake one.
test_mailhost2
Note that this is fixed here https://github.com/plone/plone.app.testing/commit/0882636c708f68072c442766d3f6af38bd4b2b08 or by replacing MOCK_MAILHOST_FIXTURE with:
from plone.app.testing.layers import MockMailHostLayer ... bases=(MY_FIXTURE1, MockMailHostLayer()), name="My:Integration1" ...
Either I am using the fixture improperly or there is an issue.
If the latter I am not sure what is the best way to fix it. Should we:
MockMailHostLayer()
# coding=utf-8 from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE from plone.app.testing import IntegrationTesting from plone.app.testing import PloneSandboxLayer from plone.app.testing.layers import MOCK_MAILHOST_FIXTURE from plone.app.testing.utils import MockMailHost from unittest import TestCase class MyFixture1(PloneSandboxLayer): defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,) class MyFixture2(PloneSandboxLayer): defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,) MY_FIXTURE1 = MyFixture1() MY_FIXTURE2 = MyFixture2() MY_TESTING1 = IntegrationTesting( bases=(MY_FIXTURE1, MOCK_MAILHOST_FIXTURE), name="My:Integration1" ) MY_TESTING2 = IntegrationTesting( bases=(MY_FIXTURE2, MOCK_MAILHOST_FIXTURE), name="My:Integration2" ) class TestCase1(TestCase): layer = MY_TESTING1 def test_mailhost1(self): self.assertIsInstance(self.layer["portal"].MailHost, MockMailHost) class TestCase2(TestCase): layer = MY_TESTING2 def test_mailhost2(self): self.assertIsInstance(self.layer["portal"].MailHost, MockMailHost)
I have this file (see bottom of the issue) with two tests that use the
MOCK_MAILHOST_FIXTURE
as stated in the documentation:If now I run:
or
The
test_mailhost2
is failing because the portal mailhost is not the fake one.Note that this is fixed here https://github.com/plone/plone.app.testing/commit/0882636c708f68072c442766d3f6af38bd4b2b08 or by replacing
MOCK_MAILHOST_FIXTURE
with:Either I am using the fixture improperly or there is an issue.
If the latter I am not sure what is the best way to fix it. Should we:
MockMailHostLayer()
for every layerMinimal file that can be used to reproduce the issue.