Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Refactors test_urlrequest.py #6951

Merged
merged 1 commit into from
Jun 18, 2020

Conversation

AndreMiras
Copy link
Member

  • uses @pytest.mark.skipif() rather than return
  • couple of DRY fixes using helper functions


def __init__(self, queue):
super(UrlRequestQueue, self).__init__()
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed because we don't inherit from anything


queue = []
Copy link
Member Author

Choose a reason for hiding this comment

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

The queue is already defined in the init, less is more. Having it defined here can lead to the misleading assumption we want it to be static attribute

timed_out = False
while not request.is_finished and not timed_out:
Clock.tick()
sleep(.1)
Copy link
Member Author

Choose a reason for hiding this comment

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

reduced the sleep time from .5 to .1 because nobody likes to wait :)

@AndreMiras AndreMiras requested a review from matham June 17, 2020 21:28
@AndreMiras
Copy link
Member Author

A small test refactoring before addressing #6946, also refs https://discord.com/channels/423249981340778496/490493814281338890/722883388889104446

Copy link
Member

@matham matham left a comment

Choose a reason for hiding this comment

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

What's up with the :recycle: in the title?

from time import sleep
from base64 import b64encode
import os

if not os.environ.get('NONETWORK'):
from kivy.network.urlrequest import UrlRequest
from kivy.clock import Clock
Copy link
Member

Choose a reason for hiding this comment

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

Can you use the kivy_clock fixture and pass it in, instead of importing it?

Also, I don't like when we import kivy things globally in tests because then the kivy stuff is initialized before the tests start because kivy imports are so aggressive. It'd be better if you just do from kivy.network.urlrequest import UrlRequest in each test.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated the code as per your suggestion.
Out of curiosity, regarding kivy imports being aggressive. Dont't we have a deeper problem we want to fix one day? Or is it a feature that can't be fixed or that we don't want to fix?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we do have a very deep problem there that I hope will be fixed one day (the sooner the better). So this is just in preparation for that bright sunny morning :D

- uses @pytest.mark.skipif() rather than return
- couple of DRY fixes using helper functions
- uses the kivy_clock fixture
@AndreMiras AndreMiras force-pushed the feature/test_urlrequest_refactor branch from c934516 to cdb8956 Compare June 18, 2020 07:15
@AndreMiras
Copy link
Member Author

Addressed all the comments, including:

What's up with the ♻️ in the title?

It's commit emoji, https://gitmoji.carloscuesta.me/ I assume you didn't like it, so I removed it 😄

@AndreMiras AndreMiras requested a review from matham June 18, 2020 07:28
Copy link
Member

@matham matham left a comment

Choose a reason for hiding this comment

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

Looks good!!

@AndreMiras AndreMiras merged commit e4de92c into kivy:master Jun 18, 2020
@AndreMiras AndreMiras deleted the feature/test_urlrequest_refactor branch June 18, 2020 15:39
@matham
Copy link
Member

matham commented Jun 18, 2020

Oh, it didn't render as a ♻️ in the title so I was confused by what it was supposed to be.

@AndreMiras
Copy link
Member Author

Yes, BTW, I just see the merge message picked the GitHub title rather than the actual commit title. So now we have a merge commit with the icon 🤦‍♂️

@matham matham added this to the 2.0.0 milestone Oct 28, 2020
@matham matham changed the title ♻️ Refactors test_urlrequest.py Tests: Refactors test_urlrequest.py Dec 9, 2020
@matham matham added the Component: tests/CI Tests, CI, GitHub settings label Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: tests/CI Tests, CI, GitHub settings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants