diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-07-22 09:06:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-22 09:06:46 (GMT) |
commit | 67748f18c9b53def23f7614759fb632165f50d6a (patch) | |
tree | 0d2e7c62e551c8bd6dc9199360518096975506a2 /Lib/test | |
parent | 9cbde7c6ce6f7b93301a37f03dfa0c0d45e00a39 (diff) | |
download | cpython-67748f18c9b53def23f7614759fb632165f50d6a.zip cpython-67748f18c9b53def23f7614759fb632165f50d6a.tar.gz cpython-67748f18c9b53def23f7614759fb632165f50d6a.tar.bz2 |
[3.12] gh-106970: Fix Argument Clinic 'destination <name> clear' command (GH-106972) (#106983)
Add test for the 'destination <name> clear' command,
and the 'destination' directive in general.
Fix two bugs in 'destination <name> clear' command:
1. The text attribute of the allocator is called 'text', not '_text'
2. Return after processing the 'clear' command,
instead of proceeding directly to the fail().
(cherry picked from commit 3372bcba9893030e4063a9264ec0b4d1b6166883)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/clinic.test.c | 56 | ||||
-rw-r--r-- | Lib/test/test_clinic.py | 9 |
2 files changed, 65 insertions, 0 deletions
diff --git a/Lib/test/clinic.test.c b/Lib/test/clinic.test.c index 5748bbc..04227e4 100644 --- a/Lib/test/clinic.test.c +++ b/Lib/test/clinic.test.c @@ -4954,3 +4954,59 @@ Test_meth_coexist(TestObj *self, PyObject *Py_UNUSED(ignored)) static PyObject * Test_meth_coexist_impl(TestObj *self) /*[clinic end generated code: output=808a293d0cd27439 input=2a1d75b5e6fec6dd]*/ + + +/*[clinic input] +output push +output preset buffer +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=5bff3376ee0df0b5]*/ + +/*[clinic input] +buffer_clear + a: int +We'll call 'destination buffer clear' after this. + +Argument Clinic's buffer preset puts most generated code into the +'buffer' destination, except from 'impl_definition', which is put into +the 'block' destination, so we should expect everything but +'impl_definition' to be cleared. +[clinic start generated code]*/ + +static PyObject * +buffer_clear_impl(PyObject *module, int a) +/*[clinic end generated code: output=f14bba74677e1846 input=a4c308a6fdab043c]*/ + +/*[clinic input] +destination buffer clear +output pop +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=f20d06adb8252084]*/ + + +/*[clinic input] +output push +destination test1 new buffer +output everything suppress +output docstring_definition test1 +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=5a77c454970992fc]*/ + +/*[clinic input] +new_dest + a: int +Only this docstring should be outputted to test1. +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=da5af421ed8996ed]*/ + +/*[clinic input] +dump test1 +output pop +[clinic start generated code]*/ + +PyDoc_STRVAR(new_dest__doc__, +"new_dest($module, /, a)\n" +"--\n" +"\n" +"Only this docstring should be outputted to test1."); +/*[clinic end generated code: output=9cac703f51d90e84 input=090db8df4945576d]*/ diff --git a/Lib/test/test_clinic.py b/Lib/test/test_clinic.py index 7c725e3..e40579b 100644 --- a/Lib/test/test_clinic.py +++ b/Lib/test/test_clinic.py @@ -249,6 +249,15 @@ class ClinicWholeFileTest(_ParserBase): out = self.expect_failure(raw) self.assertEqual(out, msg) + def test_unknown_destination_command(self): + out = self.expect_failure(""" + /*[clinic input] + destination buffer nosuchcommand + [clinic start generated code]*/ + """) + msg = "unknown destination command 'nosuchcommand'" + self.assertIn(msg, out) + class ClinicGroupPermuterTest(TestCase): def _test(self, l, m, r, output): |