'Test that conftest files are using assertion rewrite on import.
(#1619)'

@pytest.mark.parametrize('initial_conftest', [True, False])
@pytest.mark.parametrize('mode', ['plain', 'rewrite'])
def test_conftest_assertion_rewrite(self, testdir, initial_conftest, mode):

    testdir.tmpdir.join('foo/tests').ensure(dir=1)
    conftest_path = ('conftest.py' if initial_conftest else 'foo/conftest.py')
    contents = {conftest_path: '\n                                                                import    pytest\n                                                                @pytest.fixture\n                                                                def    check_first():\n                                                                                def    check(values,    value):\n                                                                                                assert    values.pop(0)    ==    value\n                                                                                return    check\n                                                ', 'foo/tests/test_foo.py': '\n                                                                def    test(check_first):\n                                                                                check_first([10,    30],    30)\n                                                '}
    testdir.makepyfile(**contents)
    result = testdir.runpytest_subprocess(('--assert=%s' % mode))
    if (mode == 'plain'):
        expected = 'E                            AssertionError'
    elif (mode == 'rewrite'):
        expected = '*assert    10    ==    30*'
    else:
        assert 0
    result.stdout.fnmatch_lines([expected])
