def test_file_path(self): "Test the 'file_path' property." value = MagicMock(spec=str) rule = styles.ConstantRule(None, None) rule._file_path = value self.assertEqual(rule.file_path, value)
def test_name(self): """Test the 'name' property.""" value = MagicMock(spec=str) rule = styles.ConstantRule(None, None) rule._name = value self.assertEqual(rule.name, value)
def test___ne___different_type(self, mock_eq): """Test the ne operator when the other item isn't a StyleConstant.""" constant = styles.ConstantRule(None, None) result = constant.__ne__(MagicMock()) self.assertEqual(result, NotImplemented)
def test___ne__(self, mock_eq): """Test the ne operator.""" constant = styles.ConstantRule(None, None) mock_constant = MagicMock(spec=styles.ConstantRule) result = constant.__ne__(mock_constant) self.assertEqual(result, not mock_eq.return_value)
def test___hash__(self, mock_name_prop, mock_constant_prop): """Test the hash operator.""" constant = styles.ConstantRule(None, None) result = constant.__hash__() self.assertEqual(result, hash((constant.constant_name, constant.name))) self.assertEqual(hash(constant), hash((constant.constant_name, constant.name)))
def test___init__(self, mocker): """Test the constructor.""" mock_name = mocker.MagicMock(spec=str) mock_constant_name = mocker.MagicMock(spec=str) mock_file_path = mocker.MagicMock(spec=str) rule = styles.ConstantRule(mock_name, mock_constant_name, mock_file_path) assert rule._name == mock_name assert rule._constant_name == mock_constant_name assert rule._file_path == mock_file_path
def test___init__(self): """Test the constructor.""" mock_name = MagicMock(spec=str) mock_constant_name = MagicMock(spec=str) mock_file_path = MagicMock(spec=str) rule = styles.ConstantRule(mock_name, mock_constant_name, mock_file_path) self.assertEqual(rule._name, mock_name) self.assertEqual(rule._constant_name, mock_constant_name) self.assertEqual(rule._file_path, mock_file_path)
def test___eq__(self, mock_name_prop): """Test the equality operator.""" constant = styles.ConstantRule(None, None) mock_name_prop.return_value = "name1" mock_constant = MagicMock(spec=styles.ConstantRule) mock_constant.name = "name2" self.assertNotEqual(constant, mock_constant) mock_name_prop.return_value = "name" mock_constant.name = "name" self.assertEqual(constant, mock_constant)
def _create(): return styles.ConstantRule(None, None)