diff --git a/setup.py b/setup.py index 00e62e7..9b787b4 100644 --- a/setup.py +++ b/setup.py @@ -12,17 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os +import pathlib import setuptools -base_dir = os.path.dirname(__file__) +base_dir = pathlib.Path(__file__).parent -with open(os.path.join(base_dir, "readme_renderer", "__about__.py")) as f: +with open(base_dir.joinpath("readme_renderer", "__about__.py")) as f: about = {} exec(f.read(), about) -with open(os.path.join(base_dir, "README.rst")) as f: +with open(base_dir.joinpath("README.rst")) as f: long_description = f.read() diff --git a/tests/test_markdown.py b/tests/test_markdown.py index f886480..8d529a7 100755 --- a/tests/test_markdown.py +++ b/tests/test_markdown.py @@ -1,27 +1,17 @@ -import glob -import os +from pathlib import Path import pytest from readme_renderer.markdown import render, variants -MD_FIXTURES = [ - (fn, os.path.splitext(fn)[0] + ".html", variant) - for variant in variants - for fn in glob.iglob( - os.path.join( - os.path.dirname(__file__), - "fixtures", - "test_" + variant + "*.md" - ) - ) -] - - @pytest.mark.parametrize( ("md_filename", "html_filename", "variant"), - MD_FIXTURES, + [ + (pytest.param(fn, fn.with_suffix(".html"), variant, id=fn.name)) + for variant in variants + for fn in Path(__file__).parent.glob(f"fixtures/test_{variant}*.md") + ], ) def test_md_fixtures(md_filename, html_filename, variant): # Get our Markup diff --git a/tests/test_rst.py b/tests/test_rst.py index 5ffeae6..f1caf8d 100755 --- a/tests/test_rst.py +++ b/tests/test_rst.py @@ -1,6 +1,5 @@ import io -import glob -import os.path +from pathlib import Path import pytest @@ -10,10 +9,8 @@ @pytest.mark.parametrize( ("rst_filename", "html_filename"), [ - (fn, os.path.splitext(fn)[0] + ".html") - for fn in glob.glob( - os.path.join(os.path.dirname(__file__), "fixtures", "test_*.rst") - ) + (pytest.param(fn, fn.with_suffix(".html"), id=fn.name)) + for fn in Path(__file__).parent.glob("fixtures/test_*.rst") ], ) def test_rst_fixtures(rst_filename, html_filename): diff --git a/tests/test_txt.py b/tests/test_txt.py index d147c3b..9f4f1ac 100644 --- a/tests/test_txt.py +++ b/tests/test_txt.py @@ -1,5 +1,4 @@ -import glob -import os.path +from pathlib import Path import pytest @@ -9,10 +8,8 @@ @pytest.mark.parametrize( ("txt_filename", "html_filename"), [ - (fn, os.path.splitext(fn)[0] + ".html") - for fn in glob.glob( - os.path.join(os.path.dirname(__file__), "fixtures", "test_*.txt") - ) + (pytest.param(fn, fn.with_suffix(".html"), id=fn.name)) + for fn in Path(__file__).parent.glob("fixtures/test_*.txt") ], ) def test_txt_fixtures(txt_filename, html_filename):