Beispiel #1
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_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 #3
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 #4
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 #5
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()
    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 #7
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
 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()