testTools

Helpers for writing unit tests.

class fontTools.misc.testTools.DataFilesHandler(methodName)[source]
getpath(testfile)[source]
setUp()[source]

Hook method for setting up the test fixture before exercising it.

tearDown()[source]

Hook method for deconstructing the test fixture after testing it.

temp_dir()[source]
temp_font(font_path, file_name)[source]
class fontTools.misc.testTools.FakeFont(glyphs)[source]
get(tag, default=None)[source]
getGlyphID(name)[source]
getGlyphName(glyphID)[source]
getGlyphOrder()[source]
getReverseGlyphMap()[source]
class fontTools.misc.testTools.MockFont[source]

A font-like object that automatically adds any looked up glyphname to its glyphOrder.

getGlyphID(glyph, requireReal=None)[source]
getGlyphName(gid)[source]
getGlyphOrder()[source]
getReverseGlyphMap()[source]
class fontTools.misc.testTools.TestCase(methodName)[source]
class fontTools.misc.testTools.TestXMLReader_[source]
addCharacterData_(data)[source]
endElement_(name)[source]
startElement_(name, attrs)[source]
fontTools.misc.testTools.getXML(func, ttFont=None)[source]

Call the passed toXML function and return the written content as a list of lines (unicode strings). Result is stripped of XML declaration and OS-specific newline characters.

fontTools.misc.testTools.makeXMLWriter(newlinestr='\n')[source]
fontTools.misc.testTools.parseXML(xmlSnippet)[source]

Parses a snippet of XML.

Input can be either a single string (unicode or UTF-8 bytes), or a a sequence of strings.

The result is in the same format that would be returned by XMLReader, but the parser imposes no constraints on the root element so it can be called on small snippets of TTX files.