PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/third_party/python/pip-tools/tests/test_fake_index.py

https://bitbucket.org/vionika/spin.android
Python | 63 lines | 42 code | 19 blank | 2 comment | 5 complexity | ee279f190ba2b98d582bbca0d39c8612 MD5 | raw file
Possible License(s): JSON, 0BSD, AGPL-1.0, BSD-2-Clause, GPL-3.0, LGPL-2.1, LGPL-3.0, CC0-1.0, AGPL-3.0, MPL-2.0, Apache-2.0, MIT, BSD-3-Clause, MPL-2.0-no-copyleft-exception, GPL-2.0, Unlicense
  1. from pytest import raises
  2. def test_find_best_match(from_line, repository):
  3. ireq = from_line('django>1.5')
  4. assert str(repository.find_best_match(ireq)) == 'django==1.8'
  5. ireq = from_line('django<1.8,~=1.6')
  6. assert str(repository.find_best_match(ireq)) == 'django==1.7.7'
  7. # Extras available, but no extras specified
  8. ireq = from_line('ipython')
  9. assert str(repository.find_best_match(ireq)) == 'ipython==2.1.0'
  10. # Make sure we include extras. They should be sorted in the output.
  11. ireq = from_line('ipython[notebook,nbconvert]')
  12. assert str(repository.find_best_match(ireq)) == 'ipython[nbconvert,notebook]==2.1.0'
  13. def test_find_best_match_incl_prereleases(from_line, repository):
  14. ireq = from_line('SQLAlchemy')
  15. assert str(repository.find_best_match(ireq, prereleases=False)) == 'sqlalchemy==0.9.9'
  16. assert str(repository.find_best_match(ireq, prereleases=True)) == 'sqlalchemy==1.0.0b5'
  17. def test_find_best_match_for_editable(from_editable, repository):
  18. ireq = from_editable('git+git://whatev.org/blah.git#egg=flask')
  19. assert repository.find_best_match(ireq) == ireq
  20. def test_get_dependencies(from_line, repository):
  21. ireq = from_line('django==1.6.11')
  22. assert repository.get_dependencies(ireq) == []
  23. ireq = from_line('Flask==0.10.1')
  24. dependencies = repository.get_dependencies(ireq)
  25. assert ({str(req) for req in dependencies} ==
  26. {'Werkzeug>=0.7', 'Jinja2>=2.4', 'itsdangerous>=0.21'})
  27. ireq = from_line('ipython==2.1.0')
  28. dependencies = repository.get_dependencies(ireq)
  29. assert {str(req) for req in dependencies} == {'gnureadline'}
  30. ireq = from_line('ipython[notebook]==2.1.0')
  31. dependencies = repository.get_dependencies(ireq)
  32. assert ({str(req) for req in dependencies} ==
  33. {'gnureadline', 'pyzmq>=2.1.11', 'tornado>=3.1', 'jinja2'})
  34. ireq = from_line('ipython[notebook,nbconvert]==2.1.0')
  35. dependencies = repository.get_dependencies(ireq)
  36. assert ({str(req) for req in dependencies} ==
  37. {'gnureadline', 'pyzmq>=2.1.11', 'tornado>=3.1', 'jinja2', 'pygments', 'Sphinx>=0.3'})
  38. def test_get_dependencies_for_editable(from_editable, repository):
  39. ireq = from_editable('git+git://example.org/django.git#egg=django')
  40. assert repository.get_dependencies(ireq) == []
  41. def test_get_dependencies_rejects_non_pinned_requirements(from_line, repository):
  42. not_a_pinned_req = from_line('django>1.6')
  43. with raises(TypeError):
  44. repository.get_dependencies(not_a_pinned_req)