Skip to content

Commit

Permalink
Adding tests for bytestring docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
gdesmar committed Oct 16, 2024
1 parent 20d0a60 commit 7db6a27
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
Binary file added test/bytecode_2.7/16_bytestring_docstring.pyc
Binary file not shown.
Binary file added test/bytecode_3.8/16_no_bytestring_docstring.pyc
Binary file not shown.
45 changes: 45 additions & 0 deletions test/simple_source/stmts/16_bytestring_docstring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Module docstring"""
class A:
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == b"""Got \xe7\xfe Bytes?"""

def class_func(self):
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""

class B:
"""Got no Bytes?"""
assert __doc__ == """Got no Bytes?"""

def class_func(self):
"""Got no Bytes?"""
assert __doc__ == """Module docstring"""

def single_func():
"""single docstring?"""
assert __doc__ == """Module docstring"""

def single_byte_func():
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""

assert __doc__ == """Module docstring"""

assert single_func.__doc__ == """single docstring?"""
single_func()

assert single_byte_func.__doc__ == b"""Got \xe7\xfe Bytes?"""
single_byte_func()

assert A.__doc__ == b"""Got \xe7\xfe Bytes?"""
assert A.class_func.__doc__ == b"""Got \xe7\xfe Bytes?"""
a = A()
assert a.class_func.__doc__ == b"""Got \xe7\xfe Bytes?"""
a.class_func()

assert B.__doc__ == """Got no Bytes?"""
assert B.class_func.__doc__ == """Got no Bytes?"""
b = B()
assert b.class_func.__doc__ == """Got no Bytes?"""
b.class_func()

45 changes: 45 additions & 0 deletions test/simple_source/stmts/16_no_bytestring_docstring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Module docstring"""
class A:
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""

def class_func(self):
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""

class B:
"""Got no Bytes?"""
assert __doc__ == """Got no Bytes?"""

def class_func(self):
"""Got no Bytes?"""
assert __doc__ == """Module docstring"""

def single_func():
"""single docstring?"""
assert __doc__ == """Module docstring"""

def single_byte_func():
b"""Got \xe7\xfe Bytes?"""
assert __doc__ == """Module docstring"""

assert __doc__ == """Module docstring"""

assert single_func.__doc__ == """single docstring?"""
single_func()

assert single_byte_func.__doc__ is None
single_byte_func()

assert A.__doc__ is None
assert A.class_func.__doc__ is None
a = A()
assert a.class_func.__doc__ is None
a.class_func()

assert B.__doc__ == """Got no Bytes?"""
assert B.class_func.__doc__ == """Got no Bytes?"""
b = B()
assert b.class_func.__doc__ == """Got no Bytes?"""
b.class_func()

0 comments on commit 7db6a27

Please sign in to comment.