From f7df69b5b9d3b8698543d717918043aa6061c0be Mon Sep 17 00:00:00 2001 From: Sigmanificient Date: Thu, 25 Jul 2024 22:40:38 +0200 Subject: [PATCH] python312Packages.unicode-slugify: drop nose dependency --- .../unicode-slugify/default.nix | 20 ++++-- .../use_pytest_instead_of_nose.patch | 69 +++++++++++++++++++ 2 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 pkgs/development/python-modules/unicode-slugify/use_pytest_instead_of_nose.patch diff --git a/pkgs/development/python-modules/unicode-slugify/default.nix b/pkgs/development/python-modules/unicode-slugify/default.nix index 47a91979bf43442..32e7a66db70aa2a 100644 --- a/pkgs/development/python-modules/unicode-slugify/default.nix +++ b/pkgs/development/python-modules/unicode-slugify/default.nix @@ -2,10 +2,10 @@ lib, buildPythonPackage, fetchPypi, - nose, + fetchpatch, + pytestCheckHook, six, unidecode, - unittestCheckHook, }: buildPythonPackage rec { @@ -18,15 +18,23 @@ buildPythonPackage rec { sha256 = "25f424258317e4cb41093e2953374b3af1f23097297664731cdb3ae46f6bd6c3"; }; + patches = [ + ./use_pytest_instead_of_nose.patch + # mozilla/unicode-slugify#41: Fix Python 3.12 SyntaxWarning + (fetchpatch { + url = "https://github.com/mozilla/unicode-slugify/commit/a18826f440d0b74e536f5e32ebdcf30e720f20d8.patch"; + hash = "sha256-B27psp0XI5GhoR0l5lFpUOh88hHzjJYzJS5PnIkfFws="; + }) + ]; + propagatedBuildInputs = [ six unidecode ]; - nativeCheckInputs = [ - nose - unittestCheckHook - ]; + nativeCheckInputs = [ pytestCheckHook ]; + + pytestFlagsArray = [ "slugify/tests.py" ]; meta = with lib; { description = "Generates unicode slugs"; diff --git a/pkgs/development/python-modules/unicode-slugify/use_pytest_instead_of_nose.patch b/pkgs/development/python-modules/unicode-slugify/use_pytest_instead_of_nose.patch new file mode 100644 index 000000000000000..4aea175ffa4a5ab --- /dev/null +++ b/pkgs/development/python-modules/unicode-slugify/use_pytest_instead_of_nose.patch @@ -0,0 +1,69 @@ +diff --git a/slugify/tests.py b/slugify/tests.py +index 9f636c4..5562e87 100644 +--- a/slugify/tests.py ++++ b/slugify/tests.py +@@ -3,7 +3,7 @@ from __future__ import unicode_literals + + import six + import unittest +-from nose.tools import eq_, raises ++import pytest + + from slugify import slugify, smart_text, SLUG_OK + +@@ -13,31 +13,31 @@ def test_slugify(): + x = '-'.join([u, u]) + y = ' - '.join([u, u]) + +- @raises(ValueError) + def test_incoherent_ok_and_only_ascii_raises_an_error(): + """Checks that only_ascii=True with non ascii "ok" chars actually raises an error.""" +- slugify('angry smiley !', ok='è_é', only_ascii=True) ++ with pytest.raises(ValueError): ++ slugify('angry smiley !', ok='è_é', only_ascii=True) + + def check(x, y): +- eq_(slugify(x), y) ++ assert slugify(x) == y + + def check_only_ascii(x, y): +- eq_(slugify(x, only_ascii=True), y) ++ assert slugify(x, only_ascii=True) == y + + def check_only_ascii_capital(x, y): +- eq_(slugify(x, lower=False, only_ascii=True), y) ++ assert slugify(x, lower=False, only_ascii=True) == y + + def check_only_ascii_lower_nospaces(x, y): +- eq_(slugify(x, lower=True, spaces=False, only_ascii=True), y) ++ assert slugify(x, lower=True, spaces=False, only_ascii=True) == y + + def check_ok_chars(x, y): +- eq_(slugify(x, ok='-♰é_è'), y) ++ assert slugify(x, ok='-♰é_è') == y + + def check_empty_ok_chars(x, y): +- eq_(slugify(x, ok=''), y) ++ assert slugify(x, ok='') == y + + def check_limited_ok_chars_only_ascii(x, y): +- eq_(slugify(x, ok='-', only_ascii=True), y) ++ assert slugify(x, ok='-', only_ascii=True) == y + + s = [('xx x - "#$@ x', 'xx-x-x'), + ('Bän...g (bang)', 'bäng-bang'), +@@ -112,11 +112,11 @@ def test_slugify(): + + #Test custom space replacement + x, y = ('-☀- pretty waves under the sunset 😎', '--~pretty~waves~under~the~sunset') +- eq_(slugify(x, space_replacement='~'), y) ++ assert slugify(x, space_replacement='~') == y + + #Test default auto space replacement + x, y = ('-☀- pretty waves under the sunset 😎', 'pretty~waves~under~the~sunset') +- eq_(slugify(x, ok='~'), y) ++ assert slugify(x, ok='~') == y + + + class SmartTextTestCase(unittest.TestCase): +