From 53a9ee21d40a92b7c7cf400e402beba81c34cc72 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 17 Dec 2013 19:14:57 -0200 Subject: [PATCH] Fixed test_plugins_index to work on python 2.6 - Expected and obtained modules now use .rst to avoid being picked as doctests - Fixed test_plugins_index.expected to use the real py.test version --- doc/en/plugins_index/plugins_index.py | 6 +++--- ....expected.txt => test_plugins_index.expected.rst} | 4 ++-- doc/en/plugins_index/test_plugins_index.py | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) rename doc/en/plugins_index/{test_plugins_index.expected.txt => test_plugins_index.expected.rst} (88%) diff --git a/doc/en/plugins_index/plugins_index.py b/doc/en/plugins_index/plugins_index.py index 6cf794f22..f1cc8a465 100644 --- a/doc/en/plugins_index/plugins_index.py +++ b/doc/en/plugins_index/plugins_index.py @@ -61,7 +61,7 @@ def obtain_plugins_table(plugins, client): ColumnData = namedtuple('ColumnData', 'text link') headers = ['Name', 'Author', 'Downloads', 'Python 2.7', 'Python 3.3', 'Summary'] pytest_version = pytest.__version__ - print '*** pytest-{} ***'.format(pytest_version) + print '*** pytest-{0} ***'.format(pytest_version) plugins = list(plugins) for index, (package_name, version) in enumerate(plugins): print package_name, version, '...', @@ -127,13 +127,13 @@ def generate_plugins_index_from_table(filename, headers, rows): # table print >> f, get_row_limiter('=') for i, header in enumerate(headers): - print >> f, '{:^{fill}}'.format(header, fill=column_lengths[i]), + print >> f, '{0:^{fill}}'.format(header, fill=column_lengths[i]), print >> f print >> f, get_row_limiter('=') for column_texts in table_texts: for i, row_text in enumerate(column_texts): - print >> f, '{:^{fill}}'.format(row_text, fill=column_lengths[i]), + print >> f, '{0:^{fill}}'.format(row_text, fill=column_lengths[i]), print >> f print >> f print >> f, get_row_limiter('=') diff --git a/doc/en/plugins_index/test_plugins_index.expected.txt b/doc/en/plugins_index/test_plugins_index.expected.rst similarity index 88% rename from doc/en/plugins_index/test_plugins_index.expected.txt rename to doc/en/plugins_index/test_plugins_index.expected.rst index a78c5cbe5..2f51ad821 100644 --- a/doc/en/plugins_index/test_plugins_index.expected.txt +++ b/doc/en/plugins_index/test_plugins_index.expected.rst @@ -6,8 +6,8 @@ List of Third-Party Plugins ============================================ ============================= ========= ============================================================================================= ============================================================================================= =================== Name Author Downloads Python 2.7 Python 3.3 Summary ============================================ ============================= ========= ============================================================================================= ============================================================================================= =================== - `pytest-plugin1-1.0 `_ `someone `_ 4 .. image:: http://pytest-plugs.herokuapp.com/status/pytest-plugin1-1.0?py=py27&pytest=2.5.0 .. image:: http://pytest-plugs.herokuapp.com/status/pytest-plugin1-1.0?py=py33&pytest=2.5.0 some plugin - `pytest-plugin2-1.2 `_ `other `_ 40 .. image:: http://pytest-plugs.herokuapp.com/status/pytest-plugin2-1.2?py=py27&pytest=2.5.0 .. image:: http://pytest-plugs.herokuapp.com/status/pytest-plugin2-1.2?py=py33&pytest=2.5.0 some other plugin + `pytest-plugin1-1.0 `_ `someone `_ 4 .. image:: http://pytest-plugs.herokuapp.com/status/pytest-plugin1-1.0?py=py27&pytest=2.X.Y .. image:: http://pytest-plugs.herokuapp.com/status/pytest-plugin1-1.0?py=py33&pytest=2.X.Y some plugin + `pytest-plugin2-1.2 `_ `other `_ 40 .. image:: http://pytest-plugs.herokuapp.com/status/pytest-plugin2-1.2?py=py27&pytest=2.X.Y .. image:: http://pytest-plugs.herokuapp.com/status/pytest-plugin2-1.2?py=py33&pytest=2.X.Y some other plugin ============================================ ============================= ========= ============================================================================================= ============================================================================================= =================== diff --git a/doc/en/plugins_index/test_plugins_index.py b/doc/en/plugins_index/test_plugins_index.py index 23ff32e30..54d09b7eb 100644 --- a/doc/en/plugins_index/test_plugins_index.py +++ b/doc/en/plugins_index/test_plugins_index.py @@ -14,9 +14,9 @@ def test_plugins_index(tmpdir, monkeypatch): Blackbox testing for plugins_index script. Calls main() generating a file and compares produced output to expected. - .. note:: if the test fails, a file named `test_plugins_index.obtained` will be generated in + .. note:: if the test fails, a file named `test_plugins_index.obtained.rst` will be generated in the same directory as this test file. Ensure the contents are correct and overwrite - the global `expected_output` with the new contents. + `test_plugins_index.expected.rst` with that file. ''' import plugins_index @@ -60,7 +60,7 @@ def test_plugins_index(tmpdir, monkeypatch): monkeypatch.setattr(xmlrpclib, 'ServerProxy', DummyProxy, 'foo') monkeypatch.setattr(plugins_index, '_get_today_as_str', lambda: '2013-10-20') - output_file = str(tmpdir.join('output.txt')) + output_file = str(tmpdir.join('output.rst')) assert plugins_index.main(['', '-f', output_file, '-u', DummyProxy.expected_url]) == 0 with file(output_file, 'rU') as f: @@ -68,7 +68,7 @@ def test_plugins_index(tmpdir, monkeypatch): expected_output = get_expected_output() if obtained_output != expected_output: - obtained_file = os.path.splitext(__file__)[0] + '.obtained.txt' + obtained_file = os.path.splitext(__file__)[0] + '.obtained.rst' with file(obtained_file, 'w') as f: f.write(obtained_output) @@ -79,9 +79,9 @@ def get_expected_output(): """ :return: string with expected rst output from the plugins_index.py script. """ - expected_filename = os.path.join(os.path.dirname(__file__), 'test_plugins_index.expected.txt') + expected_filename = os.path.join(os.path.dirname(__file__), 'test_plugins_index.expected.rst') expected_output = open(expected_filename, 'rU').read() - return expected_output.replace('pytest=2.X.Y', 'pytest={}'.format(pytest.__version__)) + return expected_output.replace('pytest=2.X.Y', 'pytest={0}'.format(pytest.__version__)) #===================================================================================================