From 758f3e5aaed73af37709bbfb0d3e2287fefeab5e Mon Sep 17 00:00:00 2001 From: Pyrox Date: Sun, 28 Jul 2024 21:52:03 -0400 Subject: [PATCH 1/9] auto-convert asserts with nose2pytest --- tests/base.py | 2 +- tests/test_bug_fixes.py | 10 +++++----- tests/test_filter.py | 12 ++++++------ tests/test_formatters.py | 10 +++++----- tests/test_hidden.py | 4 ++-- tests/test_merged_cells.py | 14 +++++++------- tests/test_stringio.py | 4 ++-- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/tests/base.py b/tests/base.py index 71474a3..08b59ad 100644 --- a/tests/base.py +++ b/tests/base.py @@ -29,7 +29,7 @@ class PyexcelHatWriterBase: def test_series_table(self): pyexcel.save_as(adict=self.content, dest_file_name=self.testfile) r = pyexcel.get_sheet(file_name=self.testfile, name_columns_by_row=0) - eq_(r.dict, self.content) + assert r.dict == self.content class PyexcelWriterBase: diff --git a/tests/test_bug_fixes.py b/tests/test_bug_fixes.py index 85a97dd..17f7d7f 100644 --- a/tests/test_bug_fixes.py +++ b/tests/test_bug_fixes.py @@ -43,15 +43,15 @@ def test_issue_9_hidden_sheet(): test_file = get_fixture("hidden_sheets.xls") book_dict = pe.get_book_dict(file_name=test_file) assert "hidden" not in book_dict - eq_(book_dict["shown"], [["A", "B"]]) + assert book_dict["shown"] == [["A", "B"]] def test_issue_9_hidden_sheet_2(): test_file = get_fixture("hidden_sheets.xls") book_dict = pe.get_book_dict(file_name=test_file, skip_hidden_sheets=False) assert "hidden" in book_dict - eq_(book_dict["shown"], [["A", "B"]]) - eq_(book_dict["hidden"], [["a", "b"]]) + assert book_dict["shown"] == [["A", "B"]] + assert book_dict["hidden"] == [["a", "b"]] def test_issue_10_generator_as_content(): @@ -104,7 +104,7 @@ def test_issue_151(): skip_hidden_row_and_column=False, library="pyexcel-xls", ) - eq_("#N/A", s[0, 0]) + assert "#N/A" == s[0, 0] @raises(NotImplementedError) @@ -119,7 +119,7 @@ def test_empty_book_pyexcel_issue_120(): def test_pyexcel_issue_54(): xlvalue = 41071.0 date = xldate_to_python_date(xlvalue, 1) - eq_(date, datetime.date(2016, 6, 12)) + assert date == datetime.date(2016, 6, 12) def get_fixture(file_name): diff --git a/tests/test_filter.py b/tests/test_filter.py index cd07d3c..adf5c83 100644 --- a/tests/test_filter.py +++ b/tests/test_filter.py @@ -24,21 +24,21 @@ def test_filter_row(self): self.test_file, start_row=3, library="pyexcel-xls" ) expected = [[4, 24, 34], [5, 25, 35], [6, 26, 36]] - eq_(filtered_data[self.sheet_name], expected) + assert filtered_data[self.sheet_name] == expected def test_filter_row_2(self): filtered_data = get_data( self.test_file, start_row=3, row_limit=1, library="pyexcel-xls" ) expected = [[4, 24, 34]] - eq_(filtered_data[self.sheet_name], expected) + assert filtered_data[self.sheet_name] == expected def test_filter_column(self): filtered_data = get_data( self.test_file, start_column=1, library="pyexcel-xls" ) expected = [[21, 31], [22, 32], [23, 33], [24, 34], [25, 35], [26, 36]] - eq_(filtered_data[self.sheet_name], expected) + assert filtered_data[self.sheet_name] == expected def test_filter_column_2(self): filtered_data = get_data( @@ -48,14 +48,14 @@ def test_filter_column_2(self): library="pyexcel-xls", ) expected = [[21], [22], [23], [24], [25], [26]] - eq_(filtered_data[self.sheet_name], expected) + assert filtered_data[self.sheet_name] == expected def test_filter_both_ways(self): filtered_data = get_data( self.test_file, start_column=1, start_row=3, library="pyexcel-xls" ) expected = [[24, 34], [25, 35], [26, 36]] - eq_(filtered_data[self.sheet_name], expected) + assert filtered_data[self.sheet_name] == expected def test_filter_both_ways_2(self): filtered_data = get_data( @@ -67,7 +67,7 @@ def test_filter_both_ways_2(self): library="pyexcel-xls", ) expected = [[24]] - eq_(filtered_data[self.sheet_name], expected) + assert filtered_data[self.sheet_name] == expected def tearDown(self): os.unlink(self.test_file) diff --git a/tests/test_formatters.py b/tests/test_formatters.py index 750a60f..6c693ae 100644 --- a/tests/test_formatters.py +++ b/tests/test_formatters.py @@ -22,7 +22,7 @@ def test_reading_date_format(self): library="pyexcel-xls", ) assert isinstance(r[1, 0], datetime.date) - eq_(r[1, 0].strftime("%d/%m/%y"), "25/12/14") + assert r[1, 0].strftime("%d/%m/%y") == "25/12/14" assert isinstance(r[1, 1], datetime.time) is True assert r[1, 1].strftime("%H:%M:%S") == "11:11:11" assert r[4, 0].strftime("%d/%m/%Y") == "01/01/1900" @@ -76,7 +76,7 @@ def test_auto_detect_int(self): | 1 | 2 | 3.1 | +---+---+-----+""" ).strip() - eq_(str(sheet), expected) + assert str(sheet) == expected def test_get_book_auto_detect_int(self): book = pe.get_book(file_name=self.test_file, library="pyexcel-xls") @@ -87,7 +87,7 @@ def test_get_book_auto_detect_int(self): | 1 | 2 | 3.1 | +---+---+-----+""" ).strip() - eq_(str(book), expected) + assert str(book) == expected def test_auto_detect_int_false(self): sheet = pe.get_sheet( @@ -102,7 +102,7 @@ def test_auto_detect_int_false(self): | 1.0 | 2.0 | 3.1 | +-----+-----+-----+""" ).strip() - eq_(str(sheet), expected) + assert str(sheet) == expected def test_get_book_auto_detect_int_false(self): book = pe.get_book( @@ -117,7 +117,7 @@ def test_get_book_auto_detect_int_false(self): | 1.0 | 2.0 | 3.1 | +-----+-----+-----+""" ).strip() - eq_(str(book), expected) + assert str(book) == expected def tearDown(self): os.unlink(self.test_file) diff --git a/tests/test_hidden.py b/tests/test_hidden.py index 62d6c29..d220979 100644 --- a/tests/test_hidden.py +++ b/tests/test_hidden.py @@ -11,7 +11,7 @@ def test_simple_hidden_sheets(): skip_hidden_row_and_column=True, ) expected = [[1, 3], [7, 9]] - eq_(data["Sheet1"], expected) + assert data["Sheet1"] == expected def test_complex_hidden_sheets(): @@ -20,4 +20,4 @@ def test_complex_hidden_sheets(): skip_hidden_row_and_column=True, ) expected = [[1, 3, 5, 7, 9], [31, 33, 35, 37, 39], [61, 63, 65, 67]] - eq_(data["Sheet1"], expected) + assert data["Sheet1"] == expected diff --git a/tests/test_merged_cells.py b/tests/test_merged_cells.py index 6f243ac..839ed2f 100644 --- a/tests/test_merged_cells.py +++ b/tests/test_merged_cells.py @@ -13,7 +13,7 @@ def test_merged_cells(): library="pyexcel-xls", ) expected = [[1, 2, 3], [1, 5, 6], [1, 8, 9], [10, 11, 11]] - eq_(data["Sheet1"], expected) + assert data["Sheet1"] == expected def test_complex_merged_cells(): @@ -32,7 +32,7 @@ def test_complex_merged_cells(): [25, 25, 25, 25, 25, 25, 25, 25, 25, 25], [25, 25, 25, 25, 25, 25, 25, 25, 25, 25], ] - eq_(data["Sheet1"], expected) + assert data["Sheet1"] == expected def test_exploration(): @@ -53,9 +53,9 @@ def test_exploration(): [2], [2], ] - eq_(data["Sheet1"], expected_sheet1) + assert data["Sheet1"] == expected_sheet1 expected_sheet2 = [[3], [3], [3], [3, 4, 4, 4, 4, 4, 4], [3], [3], [3]] - eq_(data["Sheet2"], expected_sheet2) + assert data["Sheet2"] == expected_sheet2 expected_sheet3 = [ ["", "", "", "", "", 2, 2, 2], [], @@ -67,7 +67,7 @@ def test_exploration(): ["", "", "", 5], ["", "", "", 5], ] - eq_(data["Sheet3"], expected_sheet3) + assert data["Sheet3"] == expected_sheet3 def test_merged_cell_class(): @@ -76,8 +76,8 @@ def test_merged_cell_class(): merged_cell.register_cells(test_dict) keys = sorted(list(test_dict.keys())) expected = ["1-1", "1-2", "1-3", "2-1", "2-2", "2-3", "3-1", "3-2", "3-3"] - eq_(keys, expected) - eq_(merged_cell, test_dict["3-1"]) + assert keys == expected + assert merged_cell == test_dict["3-1"] def get_fixture(file_name): diff --git a/tests/test_stringio.py b/tests/test_stringio.py index e1aa055..77dbf34 100644 --- a/tests/test_stringio.py +++ b/tests/test_stringio.py @@ -17,7 +17,7 @@ def test_xls_stringio(self): ) result = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1] actual = list(r.enumerate()) - eq_(result, actual) + assert result == actual if os.path.exists(testfile): os.unlink(testfile) @@ -29,4 +29,4 @@ def test_xls_output_stringio(self): ) result = [1, 2, 3, 4, 5, 6] actual = list(r.enumerate()) - eq_(result, actual) + assert result == actual From b478029d1509a26699cbf8880e40584d1463f574 Mon Sep 17 00:00:00 2001 From: Pyrox Date: Sun, 28 Jul 2024 21:52:47 -0400 Subject: [PATCH 2/9] setUp/tearDown -> setup_method/teardown_method --- tests/test_filter.py | 4 ++-- tests/test_formatters.py | 4 ++-- tests/test_multiple_sheets.py | 10 +++++----- tests/test_writer.py | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/test_filter.py b/tests/test_filter.py index adf5c83..fe6b168 100644 --- a/tests/test_filter.py +++ b/tests/test_filter.py @@ -6,7 +6,7 @@ class TestFilter: - def setUp(self): + def setup_method(self): self.test_file = "test_filter.xls" sample = [ [1, 21, 31], @@ -69,5 +69,5 @@ def test_filter_both_ways_2(self): expected = [[24]] assert filtered_data[self.sheet_name] == expected - def tearDown(self): + def teardown_method(self): os.unlink(self.test_file) diff --git a/tests/test_formatters.py b/tests/test_formatters.py index 6c693ae..747e286 100644 --- a/tests/test_formatters.py +++ b/tests/test_formatters.py @@ -62,7 +62,7 @@ def test_writing_date_format(self): class TestAutoDetectInt: - def setUp(self): + def setup_method(self): self.content = [[1, 2, 3.1]] self.test_file = "test_auto_detect_init.xls" pe.save_as(array=self.content, dest_file_name=self.test_file) @@ -119,5 +119,5 @@ def test_get_book_auto_detect_int_false(self): ).strip() assert str(book) == expected - def tearDown(self): + def teardown_method(self): os.unlink(self.test_file) diff --git a/tests/test_multiple_sheets.py b/tests/test_multiple_sheets.py index 3f526f7..0004769 100644 --- a/tests/test_multiple_sheets.py +++ b/tests/test_multiple_sheets.py @@ -13,13 +13,13 @@ class TestXlsNxlsMultipleSheets(PyexcelMultipleSheetBase): - def setUp(self): + def setup_method(self): self.testfile = "multiple1.xls" self.testfile2 = "multiple1.xls" self.content = _produce_ordered_dict() self._write_test_file(self.testfile) - def tearDown(self): + def teardown_method(self): self._clean_up() @@ -35,7 +35,7 @@ def _write_test_file(self, file): self.rows = 3 pyexcel.save_book_as(bookdict=self.content, dest_file_name=file) - def setUp(self): + def setup_method(self): self.testfile = "multiple1.xls" self.testfile2 = "multiple2.xls" self.testfile3 = "multiple3.xls" @@ -208,7 +208,7 @@ def test_add_book_error(self): except TypeError: assert 1 == 1 - def tearDown(self): + def teardown_method(self): if os.path.exists(self.testfile): os.unlink(self.testfile) if os.path.exists(self.testfile2): @@ -216,7 +216,7 @@ def tearDown(self): class TestMultiSheetReader: - def setUp(self): + def setup_method(self): self.testfile = "file_with_an_empty_sheet.xls" def test_reader_with_correct_sheets(self): diff --git a/tests/test_writer.py b/tests/test_writer.py index 12004e8..41b7344 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -21,17 +21,17 @@ def test_write_book(self): content[key] = list(content[key]) assert content == self.content - def tearDown(self): + def teardown_method(self): if os.path.exists(self.testfile): os.unlink(self.testfile) class TestxlsnCSVWriter(PyexcelWriterBase): - def setUp(self): + def setup_method(self): self.testfile = "test.xls" self.testfile2 = "test.csv" - def tearDown(self): + def teardown_method(self): if os.path.exists(self.testfile): os.unlink(self.testfile) if os.path.exists(self.testfile2): @@ -39,9 +39,9 @@ def tearDown(self): class TestxlsHatWriter(PyexcelHatWriterBase): - def setUp(self): + def setup_method(self): self.testfile = "test.xls" - def tearDown(self): + def teardown_method(self): if os.path.exists(self.testfile): os.unlink(self.testfile) From a5f989f7341a802aedf21d1700881e52134c842a Mon Sep 17 00:00:00 2001 From: Pyrox Date: Sun, 28 Jul 2024 21:53:18 -0400 Subject: [PATCH 3/9] nose.SkipTest -> pytest.skip --- tests/test_bug_fixes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_bug_fixes.py b/tests/test_bug_fixes.py index 17f7d7f..926a05e 100644 --- a/tests/test_bug_fixes.py +++ b/tests/test_bug_fixes.py @@ -14,8 +14,8 @@ from pyexcel_xls.xlsr import xldate_to_python_date from pyexcel_xls.xlsw import XLSWriter as Writer -from nose import SkipTest from nose.tools import eq_, raises +import pytest IN_TRAVIS = "TRAVIS" in os.environ @@ -90,7 +90,7 @@ def test_issue_18_encoding_override_isnt_passed(fake_open): def test_issue_20(): if not IN_TRAVIS: - raise SkipTest() + pytest.skip("Must be in CI for this test") pe.get_book( url="https://github.com/pyexcel/pyexcel-xls/raw/master/tests/fixtures/file_with_an_empty_sheet.xls" # noqa: E501 ) @@ -98,7 +98,7 @@ def test_issue_20(): def test_issue_151(): if XLRD_VERSION_2_OR_ABOVE: - raise SkipTest() + pytest.skip("XLRD<2 required for this test") s = pe.get_sheet( file_name=get_fixture("pyexcel_issue_151.xlsx"), skip_hidden_row_and_column=False, From 32984febbba383e21356cbd04208f96de6d836f9 Mon Sep 17 00:00:00 2001 From: Pyrox Date: Sun, 28 Jul 2024 21:53:44 -0400 Subject: [PATCH 4/9] @raises -> pytest.raises --- tests/test_bug_fixes.py | 11 +++++------ tests/test_multiple_sheets.py | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/test_bug_fixes.py b/tests/test_bug_fixes.py index 926a05e..a519940 100644 --- a/tests/test_bug_fixes.py +++ b/tests/test_bug_fixes.py @@ -14,7 +14,6 @@ from pyexcel_xls.xlsr import xldate_to_python_date from pyexcel_xls.xlsw import XLSWriter as Writer -from nose.tools import eq_, raises import pytest IN_TRAVIS = "TRAVIS" in os.environ @@ -66,9 +65,9 @@ def custom_row_renderer(row): save_data("test.xls", {"sheet": data_gen()}) -@raises(IOError) def test_issue_13_empty_file_content(): - pe.get_sheet(file_content="", file_type="xls") + with pytest.raises(IOError): + pe.get_sheet(file_content="", file_type="xls") def test_issue_16_file_stream_has_no_getvalue(): @@ -107,13 +106,13 @@ def test_issue_151(): assert "#N/A" == s[0, 0] -@raises(NotImplementedError) def test_empty_book_pyexcel_issue_120(): """ https://github.com/pyexcel/pyexcel/issues/120 """ - writer = Writer("fake.xls", "xls") - writer.write({}) + with pytest.raises(NotImplementedError): + writer = Writer("fake.xls", "xls") + writer.write({}) def test_pyexcel_issue_54(): diff --git a/tests/test_multiple_sheets.py b/tests/test_multiple_sheets.py index 0004769..6708815 100644 --- a/tests/test_multiple_sheets.py +++ b/tests/test_multiple_sheets.py @@ -4,7 +4,7 @@ import pyexcel from base import PyexcelMultipleSheetBase -from nose.tools import raises +import pytest if sys.version_info[0] == 2 and sys.version_info[1] < 7: from ordereddict import OrderedDict @@ -53,13 +53,13 @@ def test_load_a_single_sheet2(self): assert len(b1.sheet_names()) == 1 assert b1["Sheet1"].to_array() == self.content["Sheet1"] - @raises(IndexError) def test_load_a_single_sheet3(self): - pyexcel.get_book(file_name=self.testfile, sheet_index=10000) + with pytest.raises(IndexError): + pyexcel.get_book(file_name=self.testfile, sheet_index=10000) - @raises(ValueError) def test_load_a_single_sheet4(self): - pyexcel.get_book(file_name=self.testfile, sheet_name="Not exist") + with pytest.raises(ValueError): + pyexcel.get_book(file_name=self.testfile, sheet_name="Not exist") def test_delete_sheets(self): b1 = pyexcel.load_book(self.testfile) From d140445ea438926caada760d56104a4161bf9b00 Mon Sep 17 00:00:00 2001 From: Pyrox Date: Sun, 28 Jul 2024 21:53:53 -0400 Subject: [PATCH 5/9] remove nose imports --- tests/base.py | 2 -- tests/test_filter.py | 2 -- tests/test_formatters.py | 2 -- tests/test_hidden.py | 2 -- tests/test_merged_cells.py | 2 -- tests/test_stringio.py | 2 -- 6 files changed, 12 deletions(-) diff --git a/tests/base.py b/tests/base.py index 08b59ad..aa7c817 100644 --- a/tests/base.py +++ b/tests/base.py @@ -3,8 +3,6 @@ import pyexcel -from nose.tools import eq_, raises # noqa - def create_sample_file1(file): data = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", 1.1, 1] diff --git a/tests/test_filter.py b/tests/test_filter.py index fe6b168..5195362 100644 --- a/tests/test_filter.py +++ b/tests/test_filter.py @@ -2,8 +2,6 @@ from pyexcel_io import get_data, save_data -from nose.tools import eq_ - class TestFilter: def setup_method(self): diff --git a/tests/test_formatters.py b/tests/test_formatters.py index 747e286..350f3d8 100644 --- a/tests/test_formatters.py +++ b/tests/test_formatters.py @@ -3,8 +3,6 @@ import pyexcel as pe -from nose.tools import eq_ - class TestDateFormat: def test_reading_date_format(self): diff --git a/tests/test_hidden.py b/tests/test_hidden.py index d220979..fcc20a4 100644 --- a/tests/test_hidden.py +++ b/tests/test_hidden.py @@ -2,8 +2,6 @@ from pyexcel_xls import get_data -from nose.tools import eq_ - def test_simple_hidden_sheets(): data = get_data( diff --git a/tests/test_merged_cells.py b/tests/test_merged_cells.py index 839ed2f..bfb54c3 100644 --- a/tests/test_merged_cells.py +++ b/tests/test_merged_cells.py @@ -3,8 +3,6 @@ from pyexcel_xls import get_data from pyexcel_xls.xlsr import MergedCell -from nose.tools import eq_ - def test_merged_cells(): data = get_data( diff --git a/tests/test_stringio.py b/tests/test_stringio.py index 77dbf34..41a25e5 100644 --- a/tests/test_stringio.py +++ b/tests/test_stringio.py @@ -3,8 +3,6 @@ import pyexcel from base import create_sample_file1 -from nose.tools import eq_ - class TestStringIO: def test_xls_stringio(self): From 9675b4303424fb40e74e4448c7e4f55fd1c9e6c3 Mon Sep 17 00:00:00 2001 From: Pyrox Date: Sun, 28 Jul 2024 21:54:02 -0400 Subject: [PATCH 6/9] update requirements files --- setup.py | 2 +- tests/requirements.txt | 5 ++--- tests/requirements3.txt | 7 ++----- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 0763a62..6aaddd2 100644 --- a/setup.py +++ b/setup.py @@ -202,7 +202,7 @@ def filter_out_test_code(file_handle): keywords=KEYWORDS, python_requires=PYTHON_REQUIRES, extras_require=EXTRAS_REQUIRE, - tests_require=["nose"], + tests_require=["pytest", "pytest-cov"], install_requires=INSTALL_REQUIRES, packages=PACKAGES, include_package_data=True, diff --git a/tests/requirements.txt b/tests/requirements.txt index 3e19c2a..49ec482 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,7 +1,6 @@ -nose +pytest +pytest-cov mock;python_version<"3" -codecov -coverage flake8 black isort diff --git a/tests/requirements3.txt b/tests/requirements3.txt index 4f61832..d730573 100644 --- a/tests/requirements3.txt +++ b/tests/requirements3.txt @@ -1,7 +1,4 @@ lxml pyexcel-ods3 -nose -rednose -nose-cov -codecov -coverage +pytest +pytest-cov From 517f48c73189fe24f35db02bbd40d100e1dacc6b Mon Sep 17 00:00:00 2001 From: Pyrox Date: Sun, 28 Jul 2024 21:54:11 -0400 Subject: [PATCH 7/9] update test scripts --- .github/workflows/tests.yml | 10 +++++----- pytest.ini | 2 ++ test.bat | 2 +- test.sh | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 pytest.ini diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 93d8a60..de91273 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,10 +7,10 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.7, 3.8, 3.9] - os: [macOs-latest, ubuntu-latest, windows-latest] + python-version: [3.7, 3.8, 3.9, 3.10, 3.11, 3.12] + os: [macos-latest, ubuntu-latest, windows-latest] exclude: - - os: macOs-latest + - os: macos-latest python-version: 3.7 runs-on: ${{ matrix.os }} @@ -28,8 +28,8 @@ jobs: - name: test run: | pip freeze - nosetests --verbosity=3 --with-coverage --cover-package pyexcel_xls --cover-package tests tests --with-doctest --doctest-extension=.rst README.rst docs/source pyexcel_xls + pytest - name: Upload coverage uses: codecov/codecov-action@v1 with: - name: ${{ matrix.os }} Python ${{ matrix.python-version }} \ No newline at end of file + name: ${{ matrix.os }} Python ${{ matrix.python-version }} diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..f731ef4 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +addopts = --cov=pyexcel_xls --doctest-glob="*.rst" tests/ README.rst docs/source pyexcel_xls diff --git a/test.bat b/test.bat index 823adb3..3387ae9 100644 --- a/test.bat +++ b/test.bat @@ -1,2 +1,2 @@ pip freeze -nosetests --with-coverage --cover-package pyexcel_xls --cover-package tests tests --with-doctest --doctest-extension=.rst README.rst docs/source pyexcel_xls +pytest diff --git a/test.sh b/test.sh index fda8353..9210de0 100644 --- a/test.sh +++ b/test.sh @@ -1,3 +1,3 @@ #/bin/bash pip freeze -nosetests --with-coverage --cover-package pyexcel_xls --cover-package tests tests --with-doctest --doctest-extension=.rst README.rst docs/source pyexcel_xls +pytest From 7c43ce8a9e7fd09e1729c0c01e4e45fffa0e5a65 Mon Sep 17 00:00:00 2001 From: Pyrox Date: Sun, 28 Jul 2024 21:54:17 -0400 Subject: [PATCH 8/9] update README --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 4dbbeae..6ac4e24 100644 --- a/README.rst +++ b/README.rst @@ -380,7 +380,7 @@ and update changelog.yml How to test your contribution ------------------------------ -Although `nose` and `doctest` are both used in code testing, it is adviable that unit tests are put in tests. `doctest` is incorporated only to make sure the code examples in documentation remain valid across different development releases. +Although `pytest` and `doctest` are both used in code testing, it is adviable that unit tests are put in tests. `doctest` is incorporated only to make sure the code examples in documentation remain valid across different development releases. On Linux/Unix systems, please launch your tests like this:: From 9f0d48035114f73077dd0f109395af32b4d9d48b Mon Sep 17 00:00:00 2001 From: Pyrox Date: Sun, 28 Jul 2024 21:55:27 -0400 Subject: [PATCH 9/9] formatting --- pyexcel_xls/__init__.py | 1 + pyexcel_xls/xlsr.py | 1 + pyexcel_xls/xlsw.py | 1 + tests/base.py | 2 +- tests/test_bug_fixes.py | 3 +-- tests/test_multiple_sheets.py | 5 ++--- tests/test_writer.py | 2 +- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/pyexcel_xls/__init__.py b/pyexcel_xls/__init__.py index 5c513bb..b890347 100644 --- a/pyexcel_xls/__init__.py +++ b/pyexcel_xls/__init__.py @@ -7,6 +7,7 @@ :copyright: (c) 2016-2021 by Onni Software Ltd :license: New BSD License """ + import xlrd # flake8: noqa diff --git a/pyexcel_xls/xlsr.py b/pyexcel_xls/xlsr.py index c9f15e8..88fe989 100644 --- a/pyexcel_xls/xlsr.py +++ b/pyexcel_xls/xlsr.py @@ -7,6 +7,7 @@ :copyright: (c) 2016-2021 by Onni Software Ltd :license: New BSD License """ + import datetime import xlrd diff --git a/pyexcel_xls/xlsw.py b/pyexcel_xls/xlsw.py index f70ec64..bbd2e67 100644 --- a/pyexcel_xls/xlsw.py +++ b/pyexcel_xls/xlsw.py @@ -7,6 +7,7 @@ :copyright: (c) 2016-2021 by Onni Software Ltd :license: New BSD License """ + import datetime import xlrd diff --git a/tests/base.py b/tests/base.py index aa7c817..1a8ef6b 100644 --- a/tests/base.py +++ b/tests/base.py @@ -81,7 +81,7 @@ def test_reading_through_sheets(self): expected = [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]] assert data == expected data = list(b["Sheet3"].rows()) - expected = [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]] + expected = [["X", "Y", "Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]] assert data == expected sheet3 = b["Sheet3"] sheet3.name_columns_by_row(0) diff --git a/tests/test_bug_fixes.py b/tests/test_bug_fixes.py index a519940..89c2464 100644 --- a/tests/test_bug_fixes.py +++ b/tests/test_bug_fixes.py @@ -8,14 +8,13 @@ import datetime from unittest.mock import MagicMock, patch +import pytest import pyexcel as pe from _compact import OrderedDict from pyexcel_xls import XLRD_VERSION_2_OR_ABOVE, save_data from pyexcel_xls.xlsr import xldate_to_python_date from pyexcel_xls.xlsw import XLSWriter as Writer -import pytest - IN_TRAVIS = "TRAVIS" in os.environ diff --git a/tests/test_multiple_sheets.py b/tests/test_multiple_sheets.py index 6708815..42b523d 100644 --- a/tests/test_multiple_sheets.py +++ b/tests/test_multiple_sheets.py @@ -1,11 +1,10 @@ import os import sys +import pytest import pyexcel from base import PyexcelMultipleSheetBase -import pytest - if sys.version_info[0] == 2 and sys.version_info[1] < 7: from ordereddict import OrderedDict else: @@ -231,6 +230,6 @@ def _produce_ordered_dict(): data_dict.update({"Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]]}) data_dict.update({"Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]]}) data_dict.update( - {"Sheet3": [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]]} + {"Sheet3": [["X", "Y", "Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]]} ) return data_dict diff --git a/tests/test_writer.py b/tests/test_writer.py index 41b7344..79759ce 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -10,7 +10,7 @@ def test_write_book(self): self.content = { "Sheet1": [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]], "Sheet2": [[4, 4, 4, 4], [5, 5, 5, 5], [6, 6, 6, 6]], - "Sheet3": [[u"X", u"Y", u"Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]], + "Sheet3": [["X", "Y", "Z"], [1, 4, 7], [2, 5, 8], [3, 6, 9]], } self.testfile = "writer.xls" writer = Writer(self.testfile, "xls")