pybites / challenges

PyBites Code Challenges
https://codechalleng.es/challenges/
692 stars 2.29k forks source link

Pcc04 #850

Closed rhyspowell closed 2 years ago

rhyspowell commented 2 years ago

ATTENTION: before clicking "Create Pull Request" please submit some meta data, thanks!

Difficulty level (1-10): [5] Estimated time spent (hours): [3] Completed (yes/no): [yes(Ish)] I stretched my coding skills (if yes what did you learn?): [] Other feedback (what can we improve?): []

rhyspowell commented 2 years ago

@bbelderbos Something off with the tests here and I cant quite wrap my head around it. I needed to update pretty much everything in the requirements file due to version issues with python 3.10. App itself runs, tests fail

AttributeError: 'tuple' object has no attribute 'user_timeline'

not sure if this is something to do with the the patch for the mock? It could be that I totally have it wrong as well, let me know

bbelderbos commented 2 years ago

@bbelderbos Something off with the tests here and I cant quite wrap my head around it. I needed to update pretty much everything in the requirements file due to version issues with python 3.10. App itself runs, tests fail

AttributeError: 'tuple' object has no attribute 'user_timeline'

not sure if this is something to do with the the patch for the mock? It could be that I totally have it wrong as well, let me know

thanks, let me try it out tomorrow ...

bbelderbos commented 2 years ago

@rhyspowell did you copy the config-template.py to config.py?

With some minor tweaks I get it working:

image

The tests use mock data so I did not need to set real Twitter API tokens and stuff.

rhyspowell commented 2 years ago

yep all of that is running, the app even runs, just getting the error on the tests.

I am using python 3.10.2 if that makes any difference @bbelderbos

image

bbelderbos commented 2 years ago

@rhyspowell hm I am on 3.10.0, what about Tweepy, I pip installed 4.11.0

bbelderbos commented 2 years ago

I thought this was mocked out? Maybe you can place a breakpoint right before this line to inspect the object?

rhyspowell commented 2 years ago

I'm on 4.10.1 of tweepy, lets see what happens if I update.

drop the break right before that line in the test. Any idea what I should be looking for?

rhyspowell commented 2 years ago

ok, so here is the output from pytest

FAILED test_usertweets.py::TestUserTweets::test_first_tweet_returned_by_api - AttributeError: 'tuple' object has no attribute 'user_timeline'
FAILED test_usertweets.py::TestUserTweets::test_num_tweets - AttributeError: 'tuple' object has no attribute 'user_timeline'
FAILED test_usertweets.py::TestUserTweets::test_read_back_from_cached_csv - AttributeError: 'tuple' object has no attribute 'user_timeline'

We are now way outside of my comfort zone 😂

rhyspowell commented 2 years ago

--- bbelderbos --- ['class', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format', 'ge', 'getattribute', 'getitem', 'gt', 'hash', 'init', 'init_subclass', 'le', 'len', 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'weakref', '_get_tweets', '_save_tweets', 'api', 'auth', 'handle', 'max_id']

Nothing even like user_timeline

bbelderbos commented 2 years ago

Haha nice :)

That version works fine for me, this is what I see in pdb on my end:

image
bbelderbos commented 2 years ago

Also from my REPL:

>>> import tweepy
>>> tweepy.API
<class 'tweepy.api.API'>
>>> "user_timeline" in dir(tweepy.API)
True
>>> tweepy.__version__
'4.10.1'
rhyspowell commented 2 years ago

ok, time i moved to pdb and not my usual print... Its going to be a learning experience

rhyspowell commented 2 years ago

ok, so calling my file directly image

running via pytest

image

with all the data above the error from running self.api

where have I broken it?

bbelderbos commented 2 years ago

@rhyspowell bit odd, maybe good to debug together at some points, because we've done the obvious checks. I am merging your submission now though so you get your Hacktoberfest credit.

rhyspowell commented 2 years ago

@bbelderbos let me know when and over what tool and we can do that.

Its already been good for me, I've learned how to map the venv in vscode and I've used PDB properly for the first time 😂

bbelderbos commented 2 years ago

@bbelderbos let me know when and over what tool and we can do that.

Its already been good for me, I've learned how to map the venv in vscode and I've used PDB properly for the first time 😂

I will ping you on Slack ...