[Python-checkins] (no subject)

Stéphane Wirtel webhook-mailer at python.org
Thu Sep 12 05:03:03 EDT 2019




To: python-checkins at python.org
Subject: bpo-18578: Rename and document test.bytecode_helper as
 test.support.bytecode_helper (GH-15168)
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

https://github.com/python/cpython/commit/92777d5e5aed1753bafe07265dbe98b2d271=
815b
commit: 92777d5e5aed1753bafe07265dbe98b2d271815b
branch: master
author: Joannah Nanjekye <33177550+nanjekyejoannah at users.noreply.github.com>
committer: St=C3=A9phane Wirtel <stephane at wirtel.be>
date: 2019-09-12T10:02:59+01:00
summary:

bpo-18578: Rename and document test.bytecode_helper as test.support.bytecode_=
helper (GH-15168)

Rename and document test.bytecode_helper as test.support.bytecode_helper

files:
A Lib/test/support/bytecode_helper.py
A Misc/NEWS.d/next/Library/2019-08-07-19-34-07.bpo-18578.xfvdb_.rst
D Lib/test/bytecode_helper.py
M Doc/library/test.rst
M Lib/test/test_dis.py
M Lib/test/test_peepholer.py

diff --git a/Doc/library/test.rst b/Doc/library/test.rst
index 6eef5c65499a..5dde55cdf951 100644
--- a/Doc/library/test.rst
+++ b/Doc/library/test.rst
@@ -1503,3 +1503,33 @@ script execution tests.
    containing the *source*.  If *compiled* is ``True``, both source files wi=
ll
    be compiled and added to the zip package.  Return a tuple of the full zip
    path and the archive name for the zip file.
+
+
+:mod:`test.support.bytecode_helper` --- Support tools for testing correct by=
tecode generation
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
+
+.. module:: test.support.bytecode_helper
+   :synopsis: Support tools for testing correct bytecode generation.
+
+The :mod:`test.support.bytecode_helper` module provides support for testing
+and inspecting bytecode generation.
+
+The module defines the follwing class:
+
+.. class:: BytecodeTestCase(unittest.TestCase)
+
+   This class has custom assertion methods for inspecting bytecode.
+
+.. method:: BytecodeTestCase.get_disassembly_as_string(co)
+
+   Return the disassembly of *co* as string.
+
+
+.. method:: BytecodeTestCase.assertInBytecode(x, opname, argval=3D_UNSPECIFI=
ED)
+
+   Return instr if *opname* is found, otherwise throws :exc:`AssertionError`.
+
+
+.. method:: BytecodeTestCase.assertNotInBytecode(x, opname, argval=3D_UNSPEC=
IFIED)
+
+   Throws :exc:`AssertionError` if *opname* is found.
diff --git a/Lib/test/bytecode_helper.py b/Lib/test/support/bytecode_helper.py
similarity index 91%
rename from Lib/test/bytecode_helper.py
rename to Lib/test/support/bytecode_helper.py
index 347d60337d76..348e277c1658 100644
--- a/Lib/test/bytecode_helper.py
+++ b/Lib/test/support/bytecode_helper.py
@@ -15,7 +15,7 @@ def get_disassembly_as_string(self, co):
         return s.getvalue()
=20
     def assertInBytecode(self, x, opname, argval=3D_UNSPECIFIED):
-        """Returns instr if op is found, otherwise throws AssertionError"""
+        """Returns instr if opname is found, otherwise throws AssertionError=
"""
         for instr in dis.get_instructions(x):
             if instr.opname =3D=3D opname:
                 if argval is _UNSPECIFIED or instr.argval =3D=3D argval:
@@ -29,7 +29,7 @@ def assertInBytecode(self, x, opname, argval=3D_UNSPECIFIED=
):
         self.fail(msg)
=20
     def assertNotInBytecode(self, x, opname, argval=3D_UNSPECIFIED):
-        """Throws AssertionError if op is found"""
+        """Throws AssertionError if opname is found"""
         for instr in dis.get_instructions(x):
             if instr.opname =3D=3D opname:
                 disassembly =3D self.get_disassembly_as_string(x)
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 11f97e6c0838..fecf203cc9b5 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -1,7 +1,7 @@
 # Minimal tests for dis module
=20
 from test.support import captured_stdout
-from test.bytecode_helper import BytecodeTestCase
+from test.support.bytecode_helper import BytecodeTestCase
 import unittest
 import sys
 import dis
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index c90a53210a93..47dee33076c5 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -1,7 +1,7 @@
 import dis
 import unittest
=20
-from test.bytecode_helper import BytecodeTestCase
+from test.support.bytecode_helper import BytecodeTestCase
=20
=20
 def count_instr_recursively(f, opname):
diff --git a/Misc/NEWS.d/next/Library/2019-08-07-19-34-07.bpo-18578.xfvdb_.rs=
t b/Misc/NEWS.d/next/Library/2019-08-07-19-34-07.bpo-18578.xfvdb_.rst
new file mode 100644
index 000000000000..cc0e02fdb394
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2019-08-07-19-34-07.bpo-18578.xfvdb_.rst
@@ -0,0 +1,2 @@
+Renamed and documented `test.bytecode_helper` as `test.support.bytecode_help=
er`.
+Patch by Joannah Nanjekye.
\ No newline at end of file



More information about the Python-checkins mailing list