示例#1
0
 def should_not_be_in(self, expected, msg=None):
     config.runtime.ignore_stack = True
     source = compat_ironpython.get_source_code()
     if source is None:
         match1 = None
         match2 = None
     else:
         m = self._should_not_be_in_variable_splitter.search(source)
         match1 = m.group(1)
         match2 = m.group(2)
     try:
         result = self.actual in expected
     except TypeError:
         msg = language.get("should_not_be_in",
                            "error",
                            sequence=self._value_with_source(
                                match2, expected))
         raise TypeError(msg)
     if result:
         msg = language.get(
             "should_not_be_in",
             "fail",
             actual_value=self._value_with_source(match1, self.actual),
             sequence=self._value_with_source(match2, expected))
         config.runtime.ignore_stack = False
         raise AssertionError(msg)
     msg = language.get("should_not_be_in",
                        "ok",
                        actual_value=self._value_with_source(
                            match1, self.actual),
                        sequence=self._value_with_source(match2, expected))
     if config.runtime.report_out:
         config.runtime.report_out.write(msg)
     config.runtime.ignore_stack = False
示例#2
0
 def should_not_be_in(self, expected, msg=None):
     config.runtime.ignore_stack = True
     source = compat_ironpython.get_source_code()
     if source is None:
          match1 = None
          match2 = None
     else:
          m = self._should_not_be_in_variable_splitter.search(source)
          match1 = m.group(1)
          match2 = m.group(2)
     try:
         result = self.actual in expected
     except TypeError:
         msg = language.get("should_not_be_in", "error",
                  sequence=self._value_with_source(match2, expected))
         raise TypeError(msg)
     if result:
         msg = language.get("should_not_be_in", "fail",
                  actual_value=self._value_with_source(match1, self.actual),
                  sequence=self._value_with_source(match2, expected))
         config.runtime.ignore_stack = False
         raise AssertionError(msg)
     msg = language.get("should_not_be_in", "ok",
              actual_value=self._value_with_source(match1, self.actual),
              sequence=self._value_with_source(match2, expected))
     if config.runtime.report_out:
         config.runtime.report_out.write(msg)
     config.runtime.ignore_stack = False
示例#3
0
 def should_include(self, expected, msg=None):
     config.runtime.ignore_stack = True
     source = compat_ironpython.get_source_code()
     if source is None:
         match1 = None
         match2 = None
     else:
         m = self._should_include_variable_splitter.search(source)
         match1 = m.group(1)
         match2 = m.group(2)
     if (not hasattr(self.actual, "__contains__")
             and not hasattr(self.actual, "__iter__")):
         msg = language.get("should_include",
                            "error",
                            variable_name=self._value_with_source(
                                match1, self.actual))
         config.runtime.ignore_stack = False
         raise TypeError(msg)
     elif not expected in self.actual:
         msg = language.get(
             "should_include",
             "fail",
             sequence=self._value_with_source(match1, self.actual),
             expected_value=self._value_with_source(match2, expected))
         config.runtime.ignore_stack = False
         raise AssertionError(msg)
     msg = language.get(
         "should_include",
         "ok",
         sequence=self._value_with_source(match1, self.actual),
         expected_value=self._value_with_source(match2, expected))
     if config.runtime.report_out:
         config.runtime.report_out.write(msg)
     config.runtime.ignore_stack = False
示例#4
0
 def should_include(self, expected, msg = None):
     config.runtime.ignore_stack = True
     source = compat_ironpython.get_source_code()
     if source is None:
          match1 = None
          match2 = None
     else:
          m = self._should_include_variable_splitter.search(source)
          match1 = m.group(1)
          match2 = m.group(2)
     if (not hasattr(self.actual, "__contains__")
         and not hasattr(self.actual, "__iter__")):
         msg = language.get("should_include", "error",
                 variable_name=self._value_with_source(match1, self.actual))
         config.runtime.ignore_stack = False
         raise TypeError(msg)
     elif not expected in self.actual:
         msg = language.get("should_include", "fail",
                 sequence=self._value_with_source(match1, self.actual),
                 expected_value=self._value_with_source(match2, expected))
         config.runtime.ignore_stack = False
         raise AssertionError(msg)
     msg = language.get("should_include", "ok",
             sequence=self._value_with_source(match1, self.actual),
             expected_value=self._value_with_source(match2, expected))
     if config.runtime.report_out:
         config.runtime.report_out.write(msg)
     config.runtime.ignore_stack = False
示例#5
0
 def should_not_be_same(self, expected, msg = None):
     """Fail if the two objects are different as determined by the 'is'
          operator.
     """
     config.runtime.ignore_stack = True
     source = compat_ironpython.get_source_code()
     if source is None:
          match1 = None
          match2 = None
     else:
          m = self._should_not_be_variable_splitter.search(source)
          match1 = m.group(1)
          match2 = m.group(2)
     if expected is self.actual:
         try:
             msg = language.get("should_not_be_same", "fail",
                     actual_expression=self._value_with_source(match1, self.actual),
                     expected_expression=self._value_with_source(match2, expected))
         except:
             msg = language.get("should_not_be_same", "fail",
                     actual_expression=self.actual,
                     expected_expression=expected)
         config.runtime.ignore_stack = False
         raise AssertionError(msg)
     try:
         msg = language.get("should_not_be_same", "ok",
                 actual_expression=self._value_with_source(match1, self.actual),
                 expected_expression=self._value_with_source(match2, expected))
     except:
         msg = language.get("should_not_be_same", "ok",
                 actual_expression=self.actual,
                 expected_expression=expected)
     if config.runtime.report_out:
         config.runtime.report_out.write(msg)
     config.runtime.ignore_stack = False
示例#6
0
 def _get_target(cls):
     source = compat_ironpython.get_source_code(3)
     if source is None:
         return None
     match = cls._target_splitter.search(source)
     if match:
         return match.group(1)
     return None
示例#7
0
 def _get_target(cls):
     source = compat_ironpython.get_source_code(3)
     if source is None:
         return None
     match = cls._target_splitter.search(source)
     if match:
         return match.group(1)
     return None
示例#8
0
 def should_not_be_same(self, expected, msg=None):
     """Fail if the two objects are different as determined by the 'is'
          operator.
     """
     config.runtime.ignore_stack = True
     source = compat_ironpython.get_source_code()
     if source is None:
         match1 = None
         match2 = None
     else:
         m = self._should_not_be_variable_splitter.search(source)
         match1 = m.group(1)
         match2 = m.group(2)
     if expected is self.actual:
         try:
             msg = language.get("should_not_be_same",
                                "fail",
                                actual_expression=self._value_with_source(
                                    match1, self.actual),
                                expected_expression=self._value_with_source(
                                    match2, expected))
         except:
             msg = language.get("should_not_be_same",
                                "fail",
                                actual_expression=self.actual,
                                expected_expression=expected)
         config.runtime.ignore_stack = False
         raise AssertionError(msg)
     try:
         msg = language.get(
             "should_not_be_same",
             "ok",
             actual_expression=self._value_with_source(match1, self.actual),
             expected_expression=self._value_with_source(match2, expected))
     except:
         msg = language.get("should_not_be_same",
                            "ok",
                            actual_expression=self.actual,
                            expected_expression=expected)
     if config.runtime.report_out:
         config.runtime.report_out.write(msg)
     config.runtime.ignore_stack = False