Skip to content

[2.7] bpo-30759: Copy test_robotparser from master#2546

Merged
vstinner merged 1 commit intopython:2.7from
vstinner:robotparser27
Jul 5, 2017
Merged

[2.7] bpo-30759: Copy test_robotparser from master#2546
vstinner merged 1 commit intopython:2.7from
vstinner:robotparser27

Conversation

@vstinner
Copy link
Copy Markdown
Member

@vstinner vstinner commented Jul 3, 2017

Copy Lib/test/test_robotparser.py from master to 2.7 and adapt it for
Python 2.7:

  • Replace urllib.robotparser with robotparser
  • Adjust HTTPServer import
  • Replace io.StringIO with StringIO.StringIO
  • Remove tests on crawl_delay() and request_rate() since these
    methods were added to Python 3
  • Remove subTest()
  • Add test_main() which explicitly lists all test cases

Comment thread Lib/test/test_robotparser.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it used?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed

Comment thread Lib/test/test_robotparser.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it used?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

removed

@serhiy-storchaka
Copy link
Copy Markdown
Member

test_robotparser was rewritten in bpo-25497 (4da0fd0) by @berkerpeksag. Maybe try to cherry-pick 4da0fd0 and compare results?

Comment thread Lib/test/test_robotparser.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

RobotHandler is a subclass of BaseHTTPServer.BaseHTTPRequestHandler, not unittest.TestCase.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed. Funny that support.run_unittest() doesn't report such bug :-)

Copy Lib/test/test_robotparser.py from master to 2.7 and adapt it for
Python 2.7:

* Replace urllib.robotparser with robotparser
* Adjust HTTPServer import
* Replace io.StringIO with StringIO.StringIO
* Remove tests on crawl_delay() and request_rate() since these
  methods were added to Python 3
* Remove subTest()
* Add test_main() which explicitly lists all test cases

Patch based on the commit 4da0fd0
written by Berker Peksag.

Co-Authored-By: Berker Peksag <[email protected]>
@vstinner
Copy link
Copy Markdown
Member Author

vstinner commented Jul 4, 2017

Oh, I don't know what happened: I did remove the 2 unused imports, but I see them in the first version of my PR? Well, it doesn't matter, I just removed them :-)

I fixed the 3 reports issues.

Serhiy: "test_robotparser was rewritten in bpo-25497 (4da0fd0) by @berkerpeksag. Maybe try to cherry-pick 4da0fd0 and compare results?"

Sorry, but I don't want to try to cherry-pick such large refactoring change from Python 3 to Python 2, the cherry-pick creates a file full of conflcts. IMHO it's simpler to start with a fresh copy of the file, and then adapt it for Python 2.

I credited @berkerpeksag in my commit message.

@vstinner
Copy link
Copy Markdown
Member Author

vstinner commented Jul 5, 2017

@serhiy-storchaka, @berkerpeksag: Does it look better now?

@vstinner vstinner merged commit 668489a into python:2.7 Jul 5, 2017
@vstinner vstinner deleted the robotparser27 branch July 5, 2017 08:00
@vstinner
Copy link
Copy Markdown
Member Author

vstinner commented Jul 5, 2017

Ok, thank you for the review @berkerpeksag. Let's go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants