Lines Matching refs:self
21 def get_header(self, data):
32 def get_msgids(self, data):
56 def extract_docstrings_from_str(self, module_content):
62 assert_python_ok(self.script, '-D', filename)
65 return self.get_msgids(data)
67 def test_header(self):
72 assert_python_ok(self.script)
75 header = self.get_header(data)
77 self.assertIn("Project-Id-Version", header)
78 self.assertIn("POT-Creation-Date", header)
79 self.assertIn("PO-Revision-Date", header)
80 self.assertIn("Last-Translator", header)
81 self.assertIn("Language-Team", header)
82 self.assertIn("MIME-Version", header)
83 self.assertIn("Content-Type", header)
84 self.assertIn("Content-Transfer-Encoding", header)
85 self.assertIn("Generated-By", header)
88 #self.assertIn("Report-Msgid-Bugs-To", header)
89 #self.assertIn("Language", header)
95 def test_POT_Creation_Date(self):
99 assert_python_ok(self.script)
102 header = self.get_header(data)
112 def test_funcdocstring(self):
114 with self.subTest(doc):
115 msgids = self.extract_docstrings_from_str(dedent('''\
119 self.assertIn('doc', msgids)
121 def test_funcdocstring_bytes(self):
122 msgids = self.extract_docstrings_from_str(dedent('''\
126 self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
128 def test_funcdocstring_fstring(self):
129 msgids = self.extract_docstrings_from_str(dedent('''\
133 self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
135 def test_classdocstring(self):
137 with self.subTest(doc):
138 msgids = self.extract_docstrings_from_str(dedent('''\
142 self.assertIn('doc', msgids)
144 def test_classdocstring_bytes(self):
145 msgids = self.extract_docstrings_from_str(dedent('''\
149 self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
151 def test_classdocstring_fstring(self):
152 msgids = self.extract_docstrings_from_str(dedent('''\
156 self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
158 def test_moduledocstring(self):
160 with self.subTest(doc):
161 msgids = self.extract_docstrings_from_str(dedent('''\
164 self.assertIn('doc', msgids)
166 def test_moduledocstring_bytes(self):
167 msgids = self.extract_docstrings_from_str(dedent('''\
170 self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
172 def test_moduledocstring_fstring(self):
173 msgids = self.extract_docstrings_from_str(dedent('''\
176 self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
178 def test_msgid(self):
179 msgids = self.extract_docstrings_from_str(
181 self.assertIn('docstring', msgids)
183 def test_msgid_bytes(self):
184 msgids = self.extract_docstrings_from_str('_(b"""doc""")')
185 self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
187 def test_msgid_fstring(self):
188 msgids = self.extract_docstrings_from_str('_(f"""doc""")')
189 self.assertFalse([msgid for msgid in msgids if 'doc' in msgid])
191 def test_funcdocstring_annotated_args(self):
193 msgids = self.extract_docstrings_from_str(dedent('''\
197 self.assertIn('doc', msgids)
199 def test_funcdocstring_annotated_return(self):
201 msgids = self.extract_docstrings_from_str(dedent('''\
205 self.assertIn('doc', msgids)
207 def test_funcdocstring_defvalue_args(self):
209 msgids = self.extract_docstrings_from_str(dedent('''\
213 self.assertIn('doc', msgids)
215 def test_funcdocstring_multiple_funcs(self):
219 msgids = self.extract_docstrings_from_str(dedent('''\
229 self.assertIn('doc1', msgids)
230 self.assertIn('doc2', msgids)
231 self.assertIn('doc3', msgids)
233 def test_classdocstring_early_colon(self):
237 msgids = self.extract_docstrings_from_str(dedent('''\
241 self.assertIn('doc', msgids)
243 def test_calls_in_fstrings(self):
244 msgids = self.extract_docstrings_from_str(dedent('''\
247 self.assertIn('foo bar', msgids)
249 def test_calls_in_fstrings_raw(self):
250 msgids = self.extract_docstrings_from_str(dedent('''\
253 self.assertIn('foo bar', msgids)
255 def test_calls_in_fstrings_nested(self):
256 msgids = self.extract_docstrings_from_str(dedent('''\
259 self.assertIn('foo bar', msgids)
261 def test_calls_in_fstrings_attribute(self):
262 msgids = self.extract_docstrings_from_str(dedent('''\
265 self.assertIn('foo bar', msgids)
267 def test_calls_in_fstrings_with_call_on_call(self):
268 msgids = self.extract_docstrings_from_str(dedent('''\
271 self.assertNotIn('foo bar', msgids)
273 def test_calls_in_fstrings_with_format(self):
274 msgids = self.extract_docstrings_from_str(dedent('''\
277 self.assertIn('foo {bar}', msgids)
279 def test_calls_in_fstrings_with_wrong_input_1(self):
280 msgids = self.extract_docstrings_from_str(dedent('''\
283 self.assertFalse([msgid for msgid in msgids if 'foo {bar}' in msgid])
285 def test_calls_in_fstrings_with_wrong_input_2(self):
286 msgids = self.extract_docstrings_from_str(dedent('''\
289 self.assertNotIn(1, msgids)
291 def test_calls_in_fstring_with_multiple_args(self):
292 msgids = self.extract_docstrings_from_str(dedent('''\
295 self.assertNotIn('foo', msgids)
296 self.assertNotIn('bar', msgids)
298 def test_calls_in_fstring_with_keyword_args(self):
299 msgids = self.extract_docstrings_from_str(dedent('''\
302 self.assertNotIn('foo', msgids)
303 self.assertNotIn('bar', msgids)
304 self.assertNotIn('baz', msgids)
306 def test_calls_in_fstring_with_partially_wrong_expression(self):
307 msgids = self.extract_docstrings_from_str(dedent('''\
310 self.assertNotIn('foo', msgids)
311 self.assertIn('bar', msgids)
313 def test_files_list(self):
333 assert_python_ok(self.script, sdir)
336 self.assertIn(f'msgid "{text1}"', data)
337 self.assertIn(f'msgid "{text2}"', data)
338 self.assertNotIn(text3, data)