GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-29598 Add couple of unit tests for pdb module by archy-rock3t-cloud · Pull Request #218 · python/cpython

Conversation

@archy-rock3t-cloud

@archy-rock3t-cloud archy-rock3t-cloud commented Feb 21, 2017

Copy link
Copy Markdown

Add unit tests for find_function, getsourcelines and lasti2lineno functions.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@the-knights-who-say-ni

the-knights-who-say-ni commented Feb 21, 2017

Copy link
Copy Markdown

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow these steps to help rectify the issue:

  1. If you don't have an account on b.p.o, please create one
  2. Make sure your GitHub username is listed in "Your Details" at b.p.o
  3. If you have not already done so, please sign the PSF contributor agreement
  4. If you just signed the CLA, please wait at least one US business day and then check "Your Details" on bugs.python.org to see if your account has been marked as having signed the CLA (the delay is due to a person having to manually check your signed CLA)
  5. Reply here saying you have completed the above steps

Thanks again to your contribution and we look forward to looking at it!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@the-knights-who-say-ni the-knights-who-say-ni added the CLA not signed label Feb 21, 2017
@Mariatta Mariatta removed the CLA not signed label Feb 21, 2017
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Feb 21, 2017
@archy-rock3t-cloud

archy-rock3t-cloud commented Feb 22, 2017

Copy link
Copy Markdown
Author

All steps listed above completed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@archy-rock3t-cloud
archy-rock3t-cloud force-pushed the bpo-29598-add-unit-tests-for-pdb branch from 2a5a46d to 3479961 Compare February 22, 2017 08:58
@archy-rock3t-cloud

archy-rock3t-cloud commented Feb 22, 2017

Copy link
Copy Markdown
Author

@Haypo @serhiy-storchaka @methane please review this PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@methane

methane commented Feb 22, 2017

Copy link
Copy Markdown
Member

Before review, why did you added test for private utility functions?
They are not covered other tests for higher level functions? Do you want cover
edge case of them which cannot test from higher level functions?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@archy-rock3t-cloud

archy-rock3t-cloud commented Feb 22, 2017

Copy link
Copy Markdown
Author

@methane, because of edge cases. Also it seems easier to write such whitebox tests for small isolated units(and this is what documentation suggests if I understood correctly). Generally I want to write tests for the whole module and because there will be quite a few tests I decided to split it into multiple small PRs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

methane
methane reviewed Feb 22, 2017
View reviewed changes
Comment thread Lib/test/test_pdb.py Outdated

@methane methane Feb 22, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for frame, *unused in inspect.getouterframes(inspect.currentframe()):

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
methane
methane reviewed Feb 22, 2017
View reviewed changes
Comment thread Lib/test/test_pdb.py Outdated

@methane methane Feb 22, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this hack to get frame object for module...
But I don't know is there any way.
I'm not expert of inspect and pdb.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
methane
methane reviewed Feb 22, 2017
View reviewed changes
Comment thread Lib/test/test_pdb.py Outdated

@methane methane Feb 22, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this test is relying implementation detail.
Doesn't #46 affects this? Is this test passes on other Python implementations like PyPy or micropython?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@xdegaye xdegaye Feb 24, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What implementation detail ?
The Python implementations like PyPy follow also the normative description of co_lnotab. I may be wrong, but differences in the definitions of the structure of the AST between those implementations should not bear any impact on the definition of the structure of co_lnotab.

As a side note, offsets increase monotonically so min_offset is the first offset yielded by findlinestarts() and max_offset is the last one (no need to invoke min() or max()).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 25, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't research deeply, I just worried. So if PyPy passes this, it's OK.

I think attributes of Python's code object is implementation detail, even though PyPy follows.
But it's not big problem until there are some Python implementation having different code implementation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@xdegaye xdegaye Feb 26, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have started a discussion on python-dev about attributes of Python code objects being implementation detail.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@xdegaye xdegaye Feb 26, 2017

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@methane
Assuming now that the specification of co_lnotab is an implementation detail, then the pdb and inspect modules from the CPython standard library may fail to run on a new Python implementation that does not follow the CPython co_lnotab specification. So why do you want to constrain test_pdb to run on this Python implementation when the pdb and inspect modules themselves would not ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xdegaye I didn't say "I want to do ...". I was asked to review, and leave comment what I feel.
I didn't say LGTM or "change required".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ignore me when my comment doesn't make sense for you.
I'm not familiar with this area.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@methane

methane commented Feb 22, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

OK. I leave some comments.

But I think I'm not suited to this change, because this code uses some inspect magic and
I'm not familiar with inspect and pdb module.
I don't know is there any better way other than than proposed magic.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@archy-rock3t-cloud

archy-rock3t-cloud commented Feb 22, 2017

Copy link
Copy Markdown
Author

@methane thank you very much for comments, can you please suggest person who can review test for pdb?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@methane

methane commented Feb 22, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I usually use Experts Index and git history to find experts.

Experts Index doesn't tell expert of pdb. But @1st1 is listed as expert of inspect module.
As reading history of pdb, @birkenfeld did very important jobs for pdb.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@methane

methane commented Feb 22, 2017

Copy link
Copy Markdown
Member

And there are some comments in b.p.o

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@archy-rock3t-cloud
bpo-29598 Add couple of unit tests for pdb module
fcf80b0
@archy-rock3t-cloud
archy-rock3t-cloud force-pushed the bpo-29598-add-unit-tests-for-pdb branch from 3479961 to fcf80b0 Compare February 22, 2017 13:49
@berkerpeksag
berkerpeksag requested a review from xdegaye February 23, 2017 07:48
@methane

methane commented Feb 28, 2017

Copy link
Copy Markdown
Member

While pdb and inspect relying on implementation, PyPy is compatible at this point.
So I don't think cpython_only is required for this, until Python 3.6 implementation
which has incompatible code object born.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

methane
methane reviewed Feb 28, 2017
View reviewed changes
Comment thread Lib/test/test_pdb.py
self.assertEqual(actual_lineno, expected_lineno)

def test_getsourcelines_with_module_frame_obj(self):
for frame, *unused in inspect.getouterframes(inspect.currentframe()):

@methane methane Feb 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like test relying on outer frame.
I like test which doesn't relying test runner implementation.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@archy-rock3t-cloud archy-rock3t-cloud Feb 28, 2017

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But documentation says that whitebox tests are preferred

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"whitebox test" is relying on implementation of test target, not test runner.

What is module_frame here? Isn't it relying on test runner?
It can be changed even if pdb and test_pdb is not changed.

So I prefer creating module frame in this test, not capturing from caller of this test.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, is there any difference between module frame and other frames from pdb's point of view?
If there is no difference, function frame is far easier to create, maybe.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@archy-rock3t-cloud archy-rock3t-cloud Feb 28, 2017 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I need specifically module frame(as you can see from pdb code itself) and it seems like it doesn't matter which module frame it will be. Can you please show how to create it manually?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

frame = inspect.currentframe()

frame must be current test's frame. caller's frame shouldn't affects this test.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@archy-rock3t-cloud archy-rock3t-cloud Feb 28, 2017

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't be module frame.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@methane methane Feb 28, 2017

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I'm sorry. I misread "I need" as "I don't need".

Now I read pdb.getsourcelines().
If I'm correct, do you want to test this one line: return lines, 1?

I don't know way to create module frame which is simple enough to test such simple one line.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@archy-rock3t-cloud archy-rock3t-cloud Feb 28, 2017

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would like it to be tested. Initially, when I've seen test coverage of stdlib I wanted to write some tests to improve it. Now it seems like tough task, because it is not even clear who should approve my PRs. If I address all comments here and in bpo, whom can I ask to approve my PR?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@archy-rock3t-cloud archy-rock3t-cloud closed this Mar 16, 2017
akruis added a commit to akruis/cpython that referenced this pull request Aug 4, 2019
@akruis
Stackless issue python#218: Cleanups and test infrastructure for embe…
7047bf0
…dded SLP

- Fix test_outside to reset cstack_base and cstack_root. Now the
simulation of a call from outside is complete.
- Add test_slp_embed to test embedding Stackless
akruis added a commit to akruis/cpython that referenced this pull request Aug 4, 2019
@akruis
Stackless issue python#218: Fix using Stackless as embedded Python in…
5b29b24
…terpreter

The fix for Stackless issue 186 (support for sub-interpreters) broke
some typical use cases.
akruis added a commit to akruis/cpython that referenced this pull request May 27, 2021
@akruis
Stackless issue python#218: Cleanups and test infrastructure for embe…
bcd0122
…dded SLP

- Fix test_outside to reset cstack_base and cstack_root. Now the
simulation of a call from outside is complete.
- Add test_slp_embed to test embedding Stackless. Currently it gets
skipped, because it requires a not yet available class.
akruis added a commit to akruis/cpython that referenced this pull request May 27, 2021
@akruis
Stackless issue python#218: Fix using Stackless as embedded Python in…
b80c026
…terpreter

The fix for Stackless issue 186 (support for sub-interpreters) broke
some typical use cases.

(cherry picked from commit 5b29b24)
@micgeronimo micgeronimo mannequin mentioned this pull request Apr 10, 2022
Write unit tests for pdb module #73784
Closed
jaraco pushed a commit that referenced this pull request Dec 2, 2022
@Mariatta
Use Python 3.6.8 runtime (#218)
f6722b5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@methane methane methane left review comments
@xdegaye xdegaye Awaiting requested review from xdegaye

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@archy-rock3t-cloud @the-knights-who-say-ni @methane @xdegaye @Mariatta
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.