From b04f959916523361e56b51b645fcedcdcbc11207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=BCtz?= Date: Fri, 30 Aug 2024 16:48:43 -0700 Subject: [PATCH] python312Packages.libcst: move tests to passthru.tests That resolves their circular dependency on hypothesmith and ufmt. --- .../python-modules/libcst/default.nix | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/pkgs/development/python-modules/libcst/default.nix b/pkgs/development/python-modules/libcst/default.nix index ab176fd8252f..447848d8afab 100644 --- a/pkgs/development/python-modules/libcst/default.nix +++ b/pkgs/development/python-modules/libcst/default.nix @@ -3,8 +3,10 @@ stdenv, buildPythonPackage, fetchFromGitHub, + callPackage, cargo, - hypothesis, + hypothesmith, + libcst, libiconv, pytestCheckHook, python, @@ -16,6 +18,7 @@ setuptools-scm, typing-extensions, typing-inspect, + ufmt, }: buildPythonPackage rec { @@ -41,12 +44,6 @@ buildPythonPackage rec { cargoRoot = "native"; - postPatch = '' - # avoid infinite recursion by not formatting the release files - substituteInPlace libcst/codegen/generate.py \ - --replace '"ufmt"' '"true"' - ''; - nativeBuildInputs = [ setuptools-rust setuptools-scm @@ -64,26 +61,30 @@ buildPythonPackage rec { ]; nativeCheckInputs = [ - hypothesis + hypothesmith pytestCheckHook + ufmt ]; preCheck = '' - # otherwise import libcst.native fails - cp build/lib.*/libcst/native.* libcst/ - - ${python.interpreter} -m libcst.codegen.generate visitors - ${python.interpreter} -m libcst.codegen.generate return_types - - # Can't run all tests due to circular dependency on hypothesmith -> libcst - rm -r {libcst/tests,libcst/codegen/tests,libcst/m*/tests} + # import from $out instead + rm libcst/__init__.py ''; disabledTests = [ - # No files are generated - "test_codemod_formatter_error_input" + # FIXME package pyre-test + "TypeInferenceProviderTest" + # we'd need to run `python -m libcst.codegen.generate all` but shouldn't modify $out + "test_codegen_clean_visitor_functions" ]; + # circular dependency on hypothesmith and ufmt + doCheck = false; + + passthru.tests = { + pytest = libcst.overridePythonAttrs { doCheck = true; }; + }; + pythonImportsCheck = [ "libcst" ]; meta = with lib; {