def _read_data(url: str) -> dict:
    response = urlopen(url)
    byts = response.read()
    data = io.stringio(byts.decode())
    reader = csv.dictreader(data)
    result = {}
    for row in reader:
        for column, value in row.items():
            result.setdefault(column, []).append(value)
    return result
def test_requirement_readout():

    if sys.version_info[0] == 3:
        from io import StringIO as stringio
    else:
        from cStringIO import StringIO as stringio

    f = """ # this is my requirements file
package-a >= 0.42
package-b
package-c
#package-e #not to be included

package-z
--no-index
-e http://example.com/mypackage-1.0.4.zip
"""

    result = load_requirements(stringio(f))
    expected = ['package-a >= 0.42', 'package-b', 'package-c', 'package-z']
    nose.tools.eq_(result, expected)
示例#3
0
def test_requirement_readout():

  if sys.version_info[0] == 3:
    from io import StringIO as stringio
  else:
    from cStringIO import StringIO as stringio

  f = """ # this is my requirements file
package-a >= 0.42
package-b
package-c
#package-e #not to be included

package-z
--no-index
-e http://example.com/mypackage-1.0.4.zip
"""

  result = load_requirements(stringio(f))
  expected = ['package-a >= 0.42', 'package-b', 'package-c', 'package-z']
  nose.tools.eq_(result, expected)
def test_documentation_generation():
    if sys.version_info[0] == 3:
        from io import StringIO as stringio
    else:
        from cStringIO import StringIO as stringio

    f = """ # this is my requirements file
package-a >= 0.42
package-b
package-c
#package-e #not to be included
setuptools

package-z
--no-index
-e http://example.com/mypackage-1.0.4.zip
"""

    # keep the nose tests quiet
    _stdout = sys.stdout

    try:
        devnull = open(os.devnull, 'w')
        sys.stdout = devnull

        # test NumPy and SciPy docs
        try:
            import numpy
            result = link_documentation(['numpy'], None)
            assert len(result) == 1
            key = list(result.keys())[0]
            assert '/numpy' in key
        except ImportError:
            pass

        try:
            import scipy
            result = link_documentation(['scipy'], None)
            assert len(result) == 1
            key = list(result.keys())[0]
            assert '/scipy' in key
            assert '/reference' in key
        except ImportError:
            pass

        try:
            import matplotlib
            result = link_documentation(['matplotlib'], None)
            assert len(result) == 1
            key = list(result.keys())[0]
            assert '/matplotlib' in key
        except ImportError:
            pass

        # test pypi packages
        additional_packages = [
            'python', 'matplotlib', 'bob.extension', 'gridtk',
            'other.bob.package'
        ]
        if "BOB_DOCUMENTATION_SERVER" not in os.environ:
            result = link_documentation(additional_packages, stringio(f))
            expected = {
                'http://docs.python.org/%d.%d' % sys.version_info[:2]: None,
                'http://matplotlib.sourceforge.net': None,
                'https://pythonhosted.org/setuptools': None,
                'https://pythonhosted.org/bob.extension': None,
                'https://pythonhosted.org/gridtk': None
            }
            nose.tools.eq_(result, expected)

        # test idiap server
        os.environ[
            "BOB_DOCUMENTATION_SERVER"] = "https://www.idiap.ch/software/bob/docs/latest/bioidiap/%s/master"
        result = link_documentation(additional_packages, stringio(f))
        expected = {
            'http://docs.python.org/%d.%d' % sys.version_info[:2]:
            None,
            'http://matplotlib.sourceforge.net':
            None,
            'https://www.idiap.ch/software/bob/docs/latest/bioidiap/bob.extension/master':
            None,
            'https://www.idiap.ch/software/bob/docs/latest/idiap/gridtk/master':
            None
        }
        nose.tools.eq_(result, expected)

    finally:
        sys.stdout = _stdout
示例#5
0
def test_documentation_generation():
  if sys.version_info[0] == 3:
    from io import StringIO as stringio
  else:
    from cStringIO import StringIO as stringio

  f = """ # this is my requirements file
package-a >= 0.42
package-b
package-c
#package-e #not to be included
setuptools

package-z
--no-index
-e http://example.com/mypackage-1.0.4.zip
"""

  # keep the nose tests quiet
  _stdout = sys.stdout

  try:
    devnull = open(os.devnull, 'w')
    sys.stdout = devnull

    # test NumPy and SciPy docs
    try:
      import numpy
      result = link_documentation(['numpy'], None)
      assert len(result) == 1
      key = list(result.keys())[0]
      assert '/numpy' in key
    except ImportError:
      pass

    try:
      import scipy
      result = link_documentation(['scipy'], None)
      assert len(result) == 1
      key = list(result.keys())[0]
      assert '/scipy' in key
      assert '/reference' in key
    except ImportError:
      pass

    try:
      import matplotlib
      result = link_documentation(['matplotlib'], None)
      assert len(result) == 1
      key = list(result.keys())[0]
      assert '/matplotlib' in key
    except ImportError:
      pass

    # test pypi packages
    additional_packages = ['python', 'matplotlib', 'bob.extension', 'gridtk', 'other.bob.package']
    if "BOB_DOCUMENTATION_SERVER" not in os.environ:
      result = link_documentation(additional_packages, stringio(f))
      expected = {'http://docs.python.org/%d.%d' % sys.version_info[:2] : None, 'http://matplotlib.sourceforge.net' : None, 'https://pythonhosted.org/setuptools' : None, 'https://pythonhosted.org/bob.extension' : None, 'https://pythonhosted.org/gridtk' : None}
      nose.tools.eq_(result, expected)

    # test idiap server
    os.environ["BOB_DOCUMENTATION_SERVER"] = "https://www.idiap.ch/software/bob/docs/latest/bioidiap/%s/master"
    result = link_documentation(additional_packages, stringio(f))
    expected = {'http://docs.python.org/%d.%d' % sys.version_info[:2] : None, 'http://matplotlib.sourceforge.net' : None, 'https://www.idiap.ch/software/bob/docs/latest/bioidiap/bob.extension/master' : None, 'https://www.idiap.ch/software/bob/docs/latest/idiap/gridtk/master' : None}
    nose.tools.eq_(result, expected)

  finally:
    sys.stdout = _stdout
示例#6
0
def test_documentation_generation():
    if sys.version_info[0] == 3:
        from io import StringIO as stringio
    else:
        from cStringIO import StringIO as stringio

    f = """ # this is my requirements file
package-a >= 0.42
package-b
package-c
#package-e #not to be included
setuptools

package-z
--no-index
-e http://example.com/mypackage-1.0.4.zip
"""

    # keep the nose tests quiet
    _stdout = sys.stdout

    try:
        devnull = open(os.devnull, 'w')
        sys.stdout = devnull

        # test NumPy and SciPy docs
        try:
            import numpy
            result = link_documentation(['numpy'], None)
            assert len(result) == 1
            key = list(result.keys())[0]
            assert 'numpy' in key
        except ImportError:
            pass

        try:
            import scipy
            result = link_documentation(['scipy'], None)
            assert len(result) == 1
            key = list(result.keys())[0]
            assert 'scipy' in key
        except ImportError:
            pass

        try:
            import matplotlib
            result = link_documentation(['matplotlib'], None)
            assert len(result) == 1
            key = list(result.keys())[0]
            assert 'matplotlib' in key
        except ImportError:
            pass

        # test pypi packages
        additional_packages = [
            'python',
            'matplotlib',
            'bob.extension',
            'gridtk',
            'other.bob.package',
        ]

        # test linkage to official documentation
        server = "http://www.idiap.ch/software/bob/docs/bob/%s/master/"
        os.environ["BOB_DOCUMENTATION_SERVER"] = server
        result = link_documentation(additional_packages, stringio(f))
        expected = [
            'https://docs.python.org/%d.%d/' % sys.version_info[:2],
            'http://matplotlib.org/',
            'https://setuptools.readthedocs.io/en/latest/',
            server % 'bob.extension',
            server % 'gridtk',
        ]
        result = [k[0] for k in result.values()]
        nose.tools.eq_(sorted(result), sorted(expected))

    finally:
        sys.stdout = _stdout