All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] support/testing: fix python_flask_expect_python
@ 2021-10-06 20:38 Yann E. MORIN
  2021-10-06 20:44 ` Thomas Petazzoni
  2021-10-12 20:54 ` Arnout Vandecappelle
  0 siblings, 2 replies; 3+ messages in thread
From: Yann E. MORIN @ 2021-10-06 20:38 UTC (permalink / raw)
  To: buildroot; +Cc: Edgar Bonet, Yann E. MORIN, Thomas Petazzoni

Commit e6ee07f41a2b (package/python-flask-expects-json: new package)
added a non-functional test case that, as noticed by Edgar, fails with:

    AssertionError: '%{http_code}' != '200'

That's because the % sign is self-escaped, à-la C, in the first part
of the command, probably to avoid its being %-formatted. But only the
second part of the command is %-formatted, so we do not need to
self-escape % in the first part.

Additionally, since eb3ee3078a76 (support/testing/infra/emulator.py:
prevent the commands from wrapping), we no longer need to play tricks
with commands that are too long to fit on the first line of the shell
prompt.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Edgar Bonet <bonet@grenoble.cnrs.fr>
---
 .../testing/tests/package/test_python_flask_expects_json.py   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/support/testing/tests/package/test_python_flask_expects_json.py b/support/testing/tests/package/test_python_flask_expects_json.py
index b7326f5d9e..5576cba2b4 100644
--- a/support/testing/tests/package/test_python_flask_expects_json.py
+++ b/support/testing/tests/package/test_python_flask_expects_json.py
@@ -17,11 +17,11 @@ class TestPythonPy3FlaskExpectsJson(TestPythonPackageBase):
     timeout = 60
 
     def try_json(self, payload, expects):
-        cmd = """curl -s -o /dev/null -w "%%{http_code}\\n" -X POST """
+        cmd = """curl -s -o /dev/null -w "%{http_code}\\n" -X POST """
         cmd += """-H "Content-Type: application/json" -d '%s' http://127.0.0.1:5000""" % payload
         output, exit_code = self.emulator.run(cmd, timeout=self.timeout)
         self.assertEqual(exit_code, 0)
-        self.assertEqual(output[-1], str(expects))
+        self.assertEqual(output[0], str(expects))
 
     def test_run(self):
         self.login()
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH] support/testing: fix python_flask_expect_python
  2021-10-06 20:38 [Buildroot] [PATCH] support/testing: fix python_flask_expect_python Yann E. MORIN
@ 2021-10-06 20:44 ` Thomas Petazzoni
  2021-10-12 20:54 ` Arnout Vandecappelle
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2021-10-06 20:44 UTC (permalink / raw)
  To: Yann E. MORIN; +Cc: Edgar Bonet, buildroot

On Wed,  6 Oct 2021 22:38:23 +0200
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> Commit e6ee07f41a2b (package/python-flask-expects-json: new package)
> added a non-functional test case that, as noticed by Edgar, fails with:
> 
>     AssertionError: '%{http_code}' != '200'
> 
> That's because the % sign is self-escaped, à-la C, in the first part
> of the command, probably to avoid its being %-formatted. But only the
> second part of the command is %-formatted, so we do not need to
> self-escape % in the first part.

Gaah, seemingly innocent-looking last minute (untested) refactoring is
ALWAYS wrong. Sorry about this and thanks for fixing my crap.

> Additionally, since eb3ee3078a76 (support/testing/infra/emulator.py:
> prevent the commands from wrapping), we no longer need to play tricks
> with commands that are too long to fit on the first line of the shell
> prompt.
> 
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Cc: Edgar Bonet <bonet@grenoble.cnrs.fr>

Looks good:

Reviewed-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Buildroot] [PATCH] support/testing: fix python_flask_expect_python
  2021-10-06 20:38 [Buildroot] [PATCH] support/testing: fix python_flask_expect_python Yann E. MORIN
  2021-10-06 20:44 ` Thomas Petazzoni
@ 2021-10-12 20:54 ` Arnout Vandecappelle
  1 sibling, 0 replies; 3+ messages in thread
From: Arnout Vandecappelle @ 2021-10-12 20:54 UTC (permalink / raw)
  To: Yann E. MORIN, buildroot; +Cc: Thomas Petazzoni, Edgar Bonet



On 06/10/2021 22:38, Yann E. MORIN wrote:
> Commit e6ee07f41a2b (package/python-flask-expects-json: new package)
> added a non-functional test case that, as noticed by Edgar, fails with:
> 
>      AssertionError: '%{http_code}' != '200'
> 
> That's because the % sign is self-escaped, à-la C, in the first part
> of the command, probably to avoid its being %-formatted. But only the
> second part of the command is %-formatted, so we do not need to
> self-escape % in the first part.
> 
> Additionally, since eb3ee3078a76 (support/testing/infra/emulator.py:
> prevent the commands from wrapping), we no longer need to play tricks
> with commands that are too long to fit on the first line of the shell
> prompt.
> 
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Cc: Edgar Bonet <bonet@grenoble.cnrs.fr>

  Applied to master, thanks.

  Regards,
  Arnout

> ---
>   .../testing/tests/package/test_python_flask_expects_json.py   | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/support/testing/tests/package/test_python_flask_expects_json.py b/support/testing/tests/package/test_python_flask_expects_json.py
> index b7326f5d9e..5576cba2b4 100644
> --- a/support/testing/tests/package/test_python_flask_expects_json.py
> +++ b/support/testing/tests/package/test_python_flask_expects_json.py
> @@ -17,11 +17,11 @@ class TestPythonPy3FlaskExpectsJson(TestPythonPackageBase):
>       timeout = 60
>   
>       def try_json(self, payload, expects):
> -        cmd = """curl -s -o /dev/null -w "%%{http_code}\\n" -X POST """
> +        cmd = """curl -s -o /dev/null -w "%{http_code}\\n" -X POST """
>           cmd += """-H "Content-Type: application/json" -d '%s' http://127.0.0.1:5000""" % payload
>           output, exit_code = self.emulator.run(cmd, timeout=self.timeout)
>           self.assertEqual(exit_code, 0)
> -        self.assertEqual(output[-1], str(expects))
> +        self.assertEqual(output[0], str(expects))
>   
>       def test_run(self):
>           self.login()
> 
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-12 20:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06 20:38 [Buildroot] [PATCH] support/testing: fix python_flask_expect_python Yann E. MORIN
2021-10-06 20:44 ` Thomas Petazzoni
2021-10-12 20:54 ` Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.