예제 #1
0
def test_get_requirements():
    "freeze.get_requirements() Should return a list of imports in a piece of code"

    # Given the following snippet
    code = '''
from mock import Mock

print(Mock())
'''

    # When I try to figure out which packages I need to run this
    # piece of code
    requirements = freeze.get_requirements(code)

    # Then I see it found the right version of 'distlib' our only
    # requirement here
    requirements.should.equal(['mock==1.0.1'])  # Guaranteed in our requirements.txt
예제 #2
0
def test_get_requirements():
    "freeze.get_requirements() Should return a list of imports in a piece of code"

    # Given the following snippet
    code = '''
from mock import Mock

print(Mock())
'''

    # When I try to figure out which packages I need to run this
    # piece of code
    requirements = freeze.get_requirements(code)

    # Then I see it found the right version of 'distlib' our only
    # requirement here
    requirements.should.equal(['mock==1.0.1'
                               ])  # Guaranteed in our requirements.txt
예제 #3
0
def test_get_requirements(get_distribution_from_source_file):
    "freeze.get_requirements() Should return a list of imports in a piece of code"

    # Given the following snippet
    code = '''
from distlib import util

print(util.in_venv())
'''

    # And a fake distribution
    distribution = Mock()
    distribution.name = 'distlib'
    distribution.version = '0.1.2'
    get_distribution_from_source_file.return_value = distribution

    # When I try to figure out which packages I need to run this
    # piece of code
    requirements = freeze.get_requirements(code)

    # Then I see it found the right version of 'distlib' our only
    # requirement here
    requirements.should.equal(['distlib==0.1.2'])
예제 #4
0
def test_get_requirements(get_distribution_from_source_file):
    "freeze.get_requirements() Should return a list of imports in a piece of code"

    # Given the following snippet
    code = '''
from distlib import util

print(util.in_venv())
'''

    # And a fake distribution
    distribution = Mock()
    distribution.name = 'distlib'
    distribution.version = '0.1.2'
    get_distribution_from_source_file.return_value = distribution

    # When I try to figure out which packages I need to run this
    # piece of code
    requirements = freeze.get_requirements(code)

    # Then I see it found the right version of 'distlib' our only
    # requirement here
    requirements.should.equal(['distlib==0.1.2'])