Skip to content

Conversation

@rhyspowell
Copy link
Contributor

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
Copy link
Contributor Author

@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
Copy link
Collaborator

@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
Copy link
Collaborator

@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
Copy link
Contributor Author

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
Copy link
Collaborator

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

@bbelderbos
Copy link
Collaborator

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

@rhyspowell
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

--- 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
Copy link
Collaborator

Haha nice :)

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

image

@bbelderbos
Copy link
Collaborator

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
Copy link
Contributor Author

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

@rhyspowell
Copy link
Contributor Author

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
Copy link
Collaborator

@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.

@bbelderbos bbelderbos merged commit ce13de0 into pybites:community Oct 31, 2022
@rhyspowell
Copy link
Contributor Author

@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
Copy link
Collaborator

@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 ...


### How do I join your Slack Community?
Use [this link](https://join.slack.com/t/pybites/shared_invite/enQtNDAxODc0MjEyODM2LTNiZjljNTI2NGJiNWI0MTRkNjY4YzQ1ZWU4MmQzNWQyN2Q4ZTQzMTk0NzkyZTRmMThlNmQzYTk5Y2Y5ZDM4NDU) - and use our #codechallenges channel for coding questions.
Use [this link](https://pybit.es/community/) - and use our #codechallenges channel for coding questions.
Copy link
Collaborator

Choose a reason for hiding this comment

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

thank you

class TestUserTweets(unittest.TestCase):
def setUp(self):
super().setUp()
with patch('tweepy.API') as mock_timeline:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cause of issue + our oversight, fixed on master (template) branch: 7221ee2 - thanks.

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.

2 participants