python-telegram-bot / ptbtest

GNU General Public License v3.0
50 stars 28 forks source link

Tests fail and run indefinitely #8

Closed j-maas closed 7 years ago

j-maas commented 7 years ago

When trying to run the tests on my machine, of the 161 tests 102 are run and 59 of those fail. The error that pops up the most is

Error
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python36-32\lib\unittest\case.py", line 59, in testPartExecutor
    yield
  File "C:\Program Files (x86)\Python36-32\lib\unittest\case.py", line 601, in run
    testMethod()
  File "C:\Users\Johannes\PycharmProjects\ptbtest\tests\test_Callbackquerygenerator.py", line 41, in test_invalid_calls
    self.cqg.get_callback_query(message=True, inline_message_id=True)
  File "C:\Users\Johannes\PycharmProjects\ptbtest\ptbtest\updategenerator.py", line 53, in decorated_func
    tmp[messtype] = func(self, *args, **kwargs)
  File "C:\Users\Johannes\PycharmProjects\ptbtest\ptbtest\callbackquerygenerator.py", line 97, in get_callback_query
    bot=self.bot.getMe()).message
  File "C:\Users\Johannes\PycharmProjects\ptbtest\ptbtest\updategenerator.py", line 53, in decorated_func
    tmp[messtype] = func(self, *args, **kwargs)
  File "C:\Users\Johannes\PycharmProjects\ptbtest\ptbtest\messagegenerator.py", line 268, in get_message
    bot=bot or self.bot)
  File "C:\Users\Admin\telegram\lib\site-packages\telegram\message.py", line 177, in __init__
    self.migrate_to_chat_id = int(migrate_to_chat_id)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

The test case test_Usergenerator/TestUserGenerator is shown as running in PyCharm. Its output is

Ran 103 tests in 1.400s

FAILED (failures=1, errors=58)

This is not picked up by PyCharm, the bar says 102 of 161 tests run. And this test does not stop running.

I am using PyCharm 2017.1 on Windows 10 and Python 3.6.1 in a virtualenv with only the requirements-dev.txt installed. The only packages not up-to-date in the virtualenv are setuptools (v28.8.0.), coverage (v4.4b1) and flake8 (v3.3.0dev0).
In the PyCharm settings, I set the test runner to be Nosetests.

Something tangential: My PR, where I fixed a link in the readme.MD did not pass the CI tests.

Eldinnie commented 7 years ago

Can you please explain how you get 161 tests?

There's 103 tests in the package which run fine on my pc.

(ENV) ***\ptbtestsuite>nosetests
***\env\lib\site-packages\urllib3\contrib\socks.py:37: DependencyWarning: SOCKS support in urllib3 requires the installation of optional dependencies: specifically, PySocks.  For more information, see https://urllib3.readthe
docs.io/en/latest/contrib.html#socks-proxies
  DependencyWarning
.................................................................................................***\ptbtestsuite\ptbtest\mockbot.py:730: UserWarning: edit_message is deprecated, use disable_edit_message instead
  'edit_message is deprecated, use disable_edit_message instead')
......
----------------------------------------------------------------------
Ran 103 tests in 2.410s

OK

On a different note, I'm running against the latest master of python-telegram-bot (since the pypi version is terrible atm). I have updated the requirements(-dev) files. this will negate the error you showed.

Lastly the failed test on the readme PR is due to sometimes travis failing a test because stopping the updater takes to long, if you rerun them they usually succeed.

j-maas commented 7 years ago

If I run nosetests in the console, I get indeed 103 tests. Still, 58 of those fail, most apparently still with the TypeError: int() argument must be a string....

I will investigate this further, after I'll return from vacation. ;)

j-maas commented 7 years ago

So I've finally got the idea of checking out old commits and seeing, if the error was introduced somwhere along the way.

I found out that it works totally fine until commit 374a46d734e073cd945bf04534fb0c3eac452638 ('Delete local deps') introduces this behaviour. I am still quite new to Python, so I do not quite understand what changed there that could have caused this issue, but I will try to investigate.

Eldinnie commented 7 years ago

I know what happened, in that commit I removed the local copy of the telegram package from the repository because changes were pulled into the master. Please run pip install -r requirements-dev -U to install the latest master version of python-telegram-bot. This complete and finish all tests

j-maas commented 7 years ago

So I just had to reload the requirements-dev.txt properly. :+1:

j-maas commented 7 years ago

On a related note, would it make sense to fix the version of the dependencies? Our IDEs should notice if there is a newer version (I hope so at least) and this would make checking out old revisions easier, I think.