# testTools

Helpers for writing unit tests.

fontTools.misc.testTools.parseXML(xmlSnippet)

  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.

fontTools.misc.testTools.parseXmlInto(font, parseInto, xmlSnippet)

class fontTools.misc.testTools.FakeFont(glyphs)

  Bases: `object`

  get(tag, default=None)
  getGlyphID(name)
  getGlyphIDMany(lst)
  getGlyphName(glyphID)
  getGlyphNameMany(lst)
  getGlyphOrder()
  getReverseGlyphMap()
  getGlyphNames()

class fontTools.misc.testTools.TestXMLReader_

  Bases: `object`

  startElement_(name, attrs)
  endElement_(name)
  addCharacterData_(data)

fontTools.misc.testTools.makeXMLWriter(newlinestr='\n')

fontTools.misc.testTools.getXML(func, ttFont=None)

  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.stripVariableItemsFromTTX(string: str, ttLibVersion: bool = True, checkSumAdjustment: bool = True, modified: bool = True, created: bool = True, sfntVersion: bool = False) → str

  Strip stuff like ttLibVersion, checksums, timestamps, etc. from TTX dumps.

class fontTools.misc.testTools.MockFont

  Bases: `object`

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

  getGlyphID(glyph)
  getReverseGlyphMap()
  getGlyphName(gid)
  getGlyphOrder()

class fontTools.misc.testTools.TestCase(methodName)

  Bases: `TestCase`

class fontTools.misc.testTools.DataFilesHandler(methodName)

  Bases: `TestCase`

  setUp()
  tearDown()
  getpath(testfile)
  temp_dir()
  temp_font(font_path, file_name)