Beispiel #1
0
    def test_getting_system_details(self):
        sys.maxunicode = 65535
        path = os.path.join(os.path.dirname(__file__), "fake-extensions")
        sys.path.append(path)
        try:
            details = util.get_system_details(True)
        finally:
            sys.path.remove(path)
        self.assertTrue(details['backends'])
        self.assertEqual(details["unicode"], "UCS2")

        sys.maxunicode = 1114111
        details = util.get_system_details(False)
        self.assertFalse(details['backends'])
        self.assertEqual(details["unicode"], "UCS4")
Beispiel #2
0
    def test_getting_system_details(self):
        sys.maxunicode = 65535
        path = os.path.join(os.path.dirname(__file__), "fake-extensions")
        sys.path.append(path)
        try:
            details = util.get_system_details(True)
        finally:
            sys.path.remove(path)
        assert details["backends"]
        assert details["unicode"] == "UCS2"

        sys.maxunicode = 1114111
        details = util.get_system_details(False)
        assert not details["backends"]
        assert details["unicode"] == "UCS4"
    def test_visa_info(self):
        """Test the visa info command line tool.

        """
        result = run('pyvisa-info', stdout=PIPE, universal_newlines=True)
        details = util.system_details_to_str(util.get_system_details())
        self.assertMultiLineEqual(result.stdout.strip(), details.strip())
Beispiel #4
0
 def test_visa_info(self):
     """Test the visa info command line tool."""
     result = run("pyvisa-info", stdout=PIPE, universal_newlines=True)
     details = util.system_details_to_str(util.get_system_details())
     # Path difference can lead to subtle differences in the backends
     # compare only the first lines.
     assert (result.stdout.strip().split("\n")[:16] ==
             details.strip().split("\n")[:16])
Beispiel #5
0
 def test_get_debug_info(self):
     details = util.system_details_to_str(util.get_system_details())
     self.assertSequenceEqual(util.get_debug_info(False), details)
     temp_stdout = StringIO()
     with contextlib.redirect_stdout(temp_stdout):
         util.get_debug_info()
     output = temp_stdout.getvalue()
     self.assertSequenceEqual(output.strip(), details.strip())
Beispiel #6
0
 def test_get_debug_info(self):
     details = util.system_details_to_str(util.get_system_details())
     assert util.get_debug_info(False) == details
     temp_stdout = StringIO()
     with contextlib.redirect_stdout(temp_stdout):
         util.get_debug_info()
     output = temp_stdout.getvalue()
     assert output.strip() == details.strip()
Beispiel #7
0
    def test_system_details_for_plugins(self):
        """Test reporting on plugins.

        """
        def dummy_list_backends():
            return ["test1", "test2", "test3", "test4"]

        def dummy_get_wrapper_class(backend):
            if backend == "test1":
                return IVIVisaLibrary

            elif backend == "test2":

                class BrokenBackend:
                    @classmethod
                    def get_debug_info(cls):
                        raise Exception()

                return BrokenBackend

            elif backend == "test4":

                class WeirdBackend:
                    @classmethod
                    def get_debug_info(cls):
                        return {"": {"": [object()]}}

                return WeirdBackend

            else:
                raise Exception()

        old_lb = highlevel.list_backends
        old_gwc = highlevel.get_wrapper_class
        highlevel.list_backends = dummy_list_backends
        highlevel.get_wrapper_class = dummy_get_wrapper_class

        try:
            details = util.get_system_details()
        finally:
            highlevel.list_backends = old_lb
            highlevel.get_wrapper_class = old_gwc

        self.assertIn("Could not instantiate", details["backends"]["test3"][0])
        self.assertIn("Could not obtain", details["backends"]["test2"][0])
        self.assertIn("Version", details["backends"]["test1"])
        self.assertIn("", details["backends"]["test4"])

        # Test converting the details to string
        util.system_details_to_str(details)
    def test_visa_main(self):
        """Test the visa scripts.

        The script is deprecated and will be removed, when it does this
        should be removed too.

        """
        result = run(["python", "-m", "visa", "info"],
                     stdout=PIPE,
                     universal_newlines=True)
        details = util.system_details_to_str(util.get_system_details())
        self.assertSequenceEqual(result.stdout.strip(), details.strip())

        with Popen(["python", "-m", "visa", "shell"], stdin=PIPE,
                   stdout=PIPE) as p:
            stdout, _ = p.communicate(b'exit')
        self.assertIn(b"Welcome to the VISA shell", stdout)
Beispiel #9
0
    def test_visa_main(self):
        """Test the visa scripts.

        The script is deprecated and will be removed, when it does this
        should be removed too.

        """
        result = run(["python", "-m", "visa", "info"],
                     stdout=PIPE,
                     universal_newlines=True)
        details = util.system_details_to_str(util.get_system_details())
        print(result.stdout.strip())
        print()
        print(details.strip())
        # Path difference can lead to subtle differences in the backends
        # compare only the first lines.
        assert (result.stdout.strip().split("\n")[:16] ==
                details.strip().split("\n")[:16])

        with Popen(["python", "-m", "visa", "shell"], stdin=PIPE,
                   stdout=PIPE) as p:
            stdout, _ = p.communicate(b"exit")
        assert b"Welcome to the VISA shell" in stdout
Beispiel #10
0
    def test_getting_system_details_with_backend(self):
        """Test getting the system details with the backend details.

        """
        details = util.get_system_details(True)
        self.assertTrue(details["backends"])
Beispiel #11
0
 def test_visa_info(self):
     """Test the visa info command line tool."""
     result = run("pyvisa-info", stdout=PIPE, universal_newlines=True)
     details = util.system_details_to_str(util.get_system_details())
     assert result.stdout.strip() == details.strip()