Belle II Software development
TolerateMissingKeyFormatterTest Class Reference
Inheritance diagram for TolerateMissingKeyFormatterTest:

Public Member Functions

def setUp (self)
 
def test_missing_key (self)
 
def test_missing_key_attribute (self)
 
def test_missing_key_item (self)
 
def test_missing_key_with_str_conversion (self)
 
def test_missing_key_with_repr_conversion (self)
 
def test_missing_key_with_conversion_and_format (self)
 
def test_missing_key_with_format (self)
 

Public Attributes

 formatter
 Use the custom string formatter that tolerates missing values for keywords.
 

Detailed Description

Test the string formatter for cases where the keys are missing

Definition at line 128 of file tolerate_missing_key_formatter.py.

Member Function Documentation

◆ setUp()

def setUp (   self)
Prepare for the string-formatter test

Definition at line 131 of file tolerate_missing_key_formatter.py.

131 def setUp(self):
132 """Prepare for the string-formatter test"""
133
134 self.formatter = TolerateMissingKeyFormatter()
135

◆ test_missing_key()

def test_missing_key (   self)
Test for a missing key

Definition at line 136 of file tolerate_missing_key_formatter.py.

136 def test_missing_key(self):
137 """Test for a missing key"""
138 template = "{present}_{missing}"
139 replaced = self.formatter.format(template, present="replaced")
140 self.assertEqual("replaced_{missing}", replaced)
141

◆ test_missing_key_attribute()

def test_missing_key_attribute (   self)
Test for a missing key attribute

Definition at line 142 of file tolerate_missing_key_formatter.py.

142 def test_missing_key_attribute(self):
143 """Test for a missing key attribute"""
144 template = "{present}_{missing.field}"
145 replaced = self.formatter.format(template, present="replaced")
146 self.assertEqual("replaced_{missing.field}", replaced)
147

◆ test_missing_key_item()

def test_missing_key_item (   self)
Test for a missing key item

Definition at line 148 of file tolerate_missing_key_formatter.py.

148 def test_missing_key_item(self):
149 """Test for a missing key item"""
150 template = "{present}_{missing[0]}"
151 replaced = self.formatter.format(template, present="replaced")
152 self.assertEqual("replaced_{missing[0]}", replaced)
153

◆ test_missing_key_with_conversion_and_format()

def test_missing_key_with_conversion_and_format (   self)
Test for a missing key item

Definition at line 166 of file tolerate_missing_key_formatter.py.

166 def test_missing_key_with_conversion_and_format(self):
167 """Test for a missing key item"""
168 template = "{present}_{missing!r:^10s}"
169 replaced = self.formatter.format(template, present="replaced")
170 self.assertEqual("replaced_{missing!r:^10s}", replaced)
171

◆ test_missing_key_with_format()

def test_missing_key_with_format (   self)
Test for a missing key item

Definition at line 172 of file tolerate_missing_key_formatter.py.

172 def test_missing_key_with_format(self):
173 """Test for a missing key item"""
174 template = "{present}_{missing:^10s}"
175 replaced = self.formatter.format(template, present="replaced")
176 self.assertEqual("replaced_{missing:^10s}", replaced)
177
178

◆ test_missing_key_with_repr_conversion()

def test_missing_key_with_repr_conversion (   self)
Test for a missing key item

Definition at line 160 of file tolerate_missing_key_formatter.py.

160 def test_missing_key_with_repr_conversion(self):
161 """Test for a missing key item"""
162 template = "{present}_{missing!r}"
163 replaced = self.formatter.format(template, present="replaced")
164 self.assertEqual("replaced_{missing!r}", replaced)
165

◆ test_missing_key_with_str_conversion()

def test_missing_key_with_str_conversion (   self)
Test for a missing key item

Definition at line 154 of file tolerate_missing_key_formatter.py.

154 def test_missing_key_with_str_conversion(self):
155 """Test for a missing key item"""
156 template = "{present}_{missing!s}"
157 replaced = self.formatter.format(template, present="replaced")
158 self.assertEqual("replaced_{missing!s}", replaced)
159

Member Data Documentation

◆ formatter

formatter

Use the custom string formatter that tolerates missing values for keywords.

Definition at line 134 of file tolerate_missing_key_formatter.py.


The documentation for this class was generated from the following file: