Page MenuHomePhabricator

UserWarning: Site objects have been created before arguments were handled
Closed, ResolvedPublic

Description

During tests there are some Userwarnings:

WARNING: c:\projects\pywikibot-g4xqx\pywikibot\bot.py:907: UserWarning: Site objects have been created before arguments were handled
  UserWarning)

This occures for script test which uses pywikibot.handle_args and using Site objects. If there are multiple tests using handle_args and Site object the second use of handle_args causes this warning because the global variable _sites is no longer empty and contains Site objects.

How to proceed in this matter?

  • filter this warning for all tests or
  • filter this warning for all related tests or
  • don't throw this warning if a test is running or
  • clear_sites dict after tests are done or
  • ?

Event Timeline

Restricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald Transcript
Xqt triaged this task as Low priority.Jun 12 2019, 8:33 AM
Xqt updated the task description. (Show Details)

clear_sites dict after tests are done

Change 571686 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [tests] Suppress Userwarning about already created sites

https://gerrit.wikimedia.org/r/571686

Change 571686 merged by jenkins-bot:
[pywikibot/core@master] [tests] Suppress Userwarning about already created sites

https://gerrit.wikimedia.org/r/571686

Change 571706 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [tests] Suppress Userwarning about already created sites

https://gerrit.wikimedia.org/r/571706

Change 571706 merged by jenkins-bot:
[pywikibot/core@master] [tests] Suppress Userwarning about already created sites

https://gerrit.wikimedia.org/r/571706

Change 677383 had a related patch set uploaded (by Damian; author: Damian):

[pywikibot/core@master] [tests] Suppress all warnings

https://gerrit.wikimedia.org/r/677383

Change 677383 merged by jenkins-bot:

[pywikibot/core@master] [tests] Suppress all warnings

https://gerrit.wikimedia.org/r/677383

Xqt removed Xqt as the assignee of this task.Apr 25 2022, 8:11 AM
Xqt removed a project: Patch-For-Review.

Change 787912 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] clear _sites cache if called with pwb wrapper

https://gerrit.wikimedia.org/r/787912

Change 787912 abandoned by Xqt:

[pywikibot/core@master] [bugfix] clear _sites cache if called with pwb wrapper

Reason:

duplicate

https://gerrit.wikimedia.org/r/787912

Change 787450 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] clear _sites cache if called with pwb wrapper

https://gerrit.wikimedia.org/r/787450

Xqt claimed this task.

Change 787450 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] clear _sites cache if called with pwb wrapper

https://gerrit.wikimedia.org/r/787450