Example #1
0
    def test_order(self):
        environ = self.environ
        environ['PYSTACIA_LIBRARY_PATH'] = self.tmproot

        v = find_library('Foo', (2, ), environ, 'windows', MockFactory())
        self.assertEqual(basename(v), 'libFoo-2.dll')

        v = find_library('Foo', (1, None), environ, 'linux', MockFactory())
        self.assertEqual(basename(v), 'libFoo.so.1')

        v = find_library('Foo', (None, ), environ, 'macos', MockFactory())
        self.assertEqual(basename(v), 'libFoo.dylib')
Example #2
0
    def test_order(self):
        environ = self.environ
        environ['PYSTACIA_LIBRARY_PATH'] = self.tmproot

        v = find_library('Foo', (2,), environ, 'windows', MockFactory())
        self.assertEqual(basename(v), 'libFoo-2.dll')

        v = find_library('Foo', (1, None), environ, 'linux', MockFactory())
        self.assertEqual(basename(v), 'libFoo.so.1')

        v = find_library('Foo', (None,), environ, 'macos', MockFactory())
        self.assertEqual(basename(v), 'libFoo.dylib')
Example #3
0
    def test_library_path(self):
        environ = self.environ
        tmproot = environ['PYSTACIA_LIBRARY_PATH'] = self.tmproot

        value = find_library('Foo', (2,), environ, 'windows', MockFactory())
        expect = join(tmproot, 'libFoo-2.dll')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (1, None), environ, 'linux', MockFactory())
        expect = join(tmproot, 'libFoo.so.1')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (None,), environ, 'macos', MockFactory())
        expect = join(tmproot, 'libFoo.dylib')
        self.assertEqual(realpath(value), realpath(expect))
Example #4
0
    def test_library_path(self):
        environ = self.environ
        tmproot = environ['PYSTACIA_LIBRARY_PATH'] = self.tmproot

        value = find_library('Foo', (2, ), environ, 'windows', MockFactory())
        expect = join(tmproot, 'libFoo-2.dll')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (1, None), environ, 'linux', MockFactory())
        expect = join(tmproot, 'libFoo.so.1')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (None, ), environ, 'macos', MockFactory())
        expect = join(tmproot, 'libFoo.dylib')
        self.assertEqual(realpath(value), realpath(expect))
Example #5
0
    def test_curdir(self):
        environ = self.environ
        tmproot = self.tmproot
        chdir(tmproot)

        value = find_library('Foo', (2,), environ, 'windows', MockFactory())
        expect = join(tmproot, 'libFoo-2.dll')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (1, None), environ, 'linux', MockFactory())
        expect = join(tmproot, 'libFoo.so.1')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (None,), environ, 'macos', MockFactory())
        expect = join(tmproot, 'libFoo.dylib')
        self.assertEqual(realpath(value), realpath(expect))
Example #6
0
    def test(self):
        environ = self.environ
        environ['PYSTACIA_LIBRARY_PATH'] = self.tmproot

        self.assertEqual(find_library('Bar', (2, 1, None)), None)
        self.assertEqual(find_library('Foo', ()), None)
        self.assertEqual(find_library('Foo', (2, 1, None), {}), None)
        # this should find something on supported OS, if it fails you need
        # to add os_name(), dll_template() support and update setUpClass
        self.assertNotEqual(
            find_library('Foo', (2, 1, None), environ, None, MockFactory()),
            None)
        # this should trick dll_template() to return None
        self.assertEqual(
            find_library('Foo', (2, 1, None), environ, '_dummy_os',
                         MockFactory()), None)
Example #7
0
    def test_curdir(self):
        environ = self.environ
        tmproot = self.tmproot
        chdir(tmproot)

        value = find_library('Foo', (2, ), environ, 'windows', MockFactory())
        expect = join(tmproot, 'libFoo-2.dll')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (1, None), environ, 'linux', MockFactory())
        expect = join(tmproot, 'libFoo.so.1')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (None, ), environ, 'macos', MockFactory())
        expect = join(tmproot, 'libFoo.dylib')
        self.assertEqual(realpath(value), realpath(expect))
Example #8
0
    def test(self):
        environ = self.environ
        environ['PYSTACIA_LIBRARY_PATH'] = self.tmproot

        self.assertEqual(find_library('Bar', (2, 1, None)), None)
        self.assertEqual(find_library('Foo', ()), None)
        self.assertEqual(find_library('Foo', (2, 1, None), {}), None)
        # this should find something on supported OS, if it fails you need
        # to add os_name(), dll_template() support and update setUpClass
        self.assertNotEqual(
            find_library('Foo', (2, 1, None), environ, None, MockFactory()),
            None)
        # this should trick dll_template() to return None
        self.assertEqual(
            find_library('Foo', (2, 1, None), environ,
                         '_dummy_os', MockFactory()),
            None)
Example #9
0
 def test_system_wide(self):
     environ = {
         'PYSTACIA_SKIP_PACKAGE': '1',
         'PYSTACIA_SKIP_VIRTUAL_ENV': '1',
         'PYSTACIA_SKIP_CWD': '1'
     }
     self.assertEqual(find_library('_YourNonExistant', (None, ), environ),
                      None)
Example #10
0
    def test_depends(self):
        this_environ = self.environ.copy()
        tmproot = join(self.tmproot, 'depends')
        this_environ['PYSTACIA_LIBRARY_PATH'] = tmproot

        environ = this_environ.copy()
        factory = MockFactory()
        find_library('Foo', (2,), environ, 'windows', factory)
        expect = [join(tmproot, x) for x in ['libDepends-18.dll',
                                             'libFoo-2.dll']]
        self.assertEqual(factory.args, expect)

        environ = this_environ.copy()
        factory = MockFactory()
        find_library('Foo', (None,), environ, 'linux', factory)
        expect = [join(tmproot, x) for x in ['libDepends.so.18', 'libFoo.so']]
        self.assertEqual(factory.args, expect)

        # throws an exception so shouldnt find anything
        environ = this_environ.copy()
        factory = MockFactory(throw=True)
        value = find_library('Foo', (1,), environ, 'macos', factory)
        expect = [join(tmproot, x) for x in ['libDepends.18.dylib',
                                             'libFoo.1.dylib']]
        self.assertEqual(value, None)
        self.assertEqual(factory.args, expect)

        # add DYLD_LIBRARY_PATH to environ for extra coverage
        environ = this_environ.copy()
        factory = MockFactory(throw=True)
        environ['DYLD_FALLBACK_LIBRARY_PATH'] = '/'
        find_library('Foo', (1,), environ, 'macos', factory)
Example #11
0
    def test_depends(self):
        this_environ = self.environ.copy()
        tmproot = join(self.tmproot, 'depends')
        this_environ['PYSTACIA_LIBRARY_PATH'] = tmproot

        environ = this_environ.copy()
        factory = MockFactory()
        find_library('Foo', (2, ), environ, 'windows', factory)
        expect = [
            join(tmproot, x) for x in ['libDepends-18.dll', 'libFoo-2.dll']
        ]
        self.assertEqual(factory.args, expect)

        environ = this_environ.copy()
        factory = MockFactory()
        find_library('Foo', (None, ), environ, 'linux', factory)
        expect = [join(tmproot, x) for x in ['libDepends.so.18', 'libFoo.so']]
        self.assertEqual(factory.args, expect)

        # throws an exception so shouldnt find anything
        environ = this_environ.copy()
        factory = MockFactory(throw=True)
        value = find_library('Foo', (1, ), environ, 'macos', factory)
        expect = [
            join(tmproot, x)
            for x in ['libDepends.18.dylib', 'libFoo.1.dylib']
        ]
        self.assertEqual(value, None)
        self.assertEqual(factory.args, expect)

        # add DYLD_LIBRARY_PATH to environ for extra coverage
        environ = this_environ.copy()
        factory = MockFactory(throw=True)
        environ['DYLD_FALLBACK_LIBRARY_PATH'] = '/'
        find_library('Foo', (1, ), environ, 'macos', factory)
Example #12
0
    def test_venv(self):
        environ = self.environ
        tmproot = environ['VIRTUAL_ENV'] = self.tmproot

        value = find_library('Foo', (2,), environ, 'windows', MockFactory())
        expect = join(tmproot, 'lib', 'libFoo-2.dll')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (1, None), environ, 'linux', MockFactory())
        expect = join(tmproot, 'lib', 'libFoo.so.1')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (None,), environ, 'macos', MockFactory())
        expect = join(tmproot, 'lib', 'libFoo.dylib')
        self.assertEqual(realpath(value), realpath(expect))

        environ['PYSTACIA_SKIP_VIRTUAL_ENV'] = '1'
        value = find_library('Foo', (None,), environ, 'macos', MockFactory())
        self.assertEqual(value, None)
Example #13
0
    def test_venv(self):
        environ = self.environ
        tmproot = environ['VIRTUAL_ENV'] = self.tmproot

        value = find_library('Foo', (2, ), environ, 'windows', MockFactory())
        expect = join(tmproot, 'lib', 'libFoo-2.dll')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (1, None), environ, 'linux', MockFactory())
        expect = join(tmproot, 'lib', 'libFoo.so.1')
        self.assertEqual(realpath(value), realpath(expect))

        value = find_library('Foo', (None, ), environ, 'macos', MockFactory())
        expect = join(tmproot, 'lib', 'libFoo.dylib')
        self.assertEqual(realpath(value), realpath(expect))

        environ['PYSTACIA_SKIP_VIRTUAL_ENV'] = '1'
        value = find_library('Foo', (None, ), environ, 'macos', MockFactory())
        self.assertEqual(value, None)
Example #14
0
 def test_system_wide(self):
     environ = {'PYSTACIA_SKIP_PACKAGE': '1',
                'PYSTACIA_SKIP_VIRTUAL_ENV': '1',
                'PYSTACIA_SKIP_CWD': '1'}
     self.assertEqual(find_library('_YourNonExistant', (None,), environ),
                      None)