Example #1
0
 def test_testForExternalChanges_remove_a_layer(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         fileSystem = openTestFontAsFileSystem(path)
         fs.copy.copy_dir(fileSystem, "glyphs", fileSystem, "glyphs.test")
         with fileSystem.open(u"layercontents.plist", "rb") as f:
             contents = load(f)
         contents.append(("test", "glyphs.test"))
         with fileSystem.open(u"layercontents.plist", "wb") as f:
             dump(contents, f)
         closeTestFontAsFileSystem(fileSystem, path)
         font = Font(path)
         fileSystem = openTestFontAsFileSystem(path)
         fileSystem.removetree(u"glyphs.test")
         with fileSystem.open(u"layercontents.plist", "rb") as f:
             contents = load(f)
         del contents[-1]
         with fileSystem.open(u"layercontents.plist", "wb") as f:
             dump(contents, f)
         closeTestFontAsFileSystem(fileSystem, path)
         reader = UFOReader(path)
         self.assertEqual(
             font.layers.testForExternalChanges(reader)["deleted"],
             ["test"])
         tearDownTestFontCopy(font.path)
Example #2
0
 def test_testForExternalChanges_change_layer_order(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         fileSystem = openTestFontAsFileSystem(path)
         fs.copy.copy_dir(fileSystem, "glyphs", fileSystem, "glyphs.test")
         with fileSystem.open(u"layercontents.plist", "rb") as f:
             contents = load(f)
         contents.append(("test", "glyphs.test"))
         with fileSystem.open(u"layercontents.plist", "wb") as f:
             dump(contents, f)
         closeTestFontAsFileSystem(fileSystem, path)
         font = Font(path)
         fileSystem = openTestFontAsFileSystem(path)
         with fileSystem.open(u"layercontents.plist", "rb") as f:
             contents = load(f)
         contents.reverse()
         with fileSystem.open(u"layercontents.plist", "wb") as f:
             dump(contents, f)
         closeTestFontAsFileSystem(fileSystem, path)
         reader = UFOReader(path)
         self.assertEqual(font.layers.testForExternalChanges(reader),
                          {"deleted": [], "added": [], "modified": {},
                           "defaultLayer": False, "order": True})
         tearDownTestFontCopy(font.path)
Example #3
0
 def test_delitem_glyph_dirty(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         glyph = font["A"]
         glyph.dirty = True
         fileSystem = openTestFontAsFileSystem(path)
         glyphPath = fs.path.join("glyphs", "A_.glif")
         fileSystem.remove(glyphPath)
         contentsPath = fs.path.join("glyphs", "contents.plist")
         with fileSystem.open(contentsPath, "rb") as f:
             plist = load(f)
         del plist["A"]
         with fileSystem.open(contentsPath, "wb") as f:
             dump(plist, f)
         closeTestFontAsFileSystem(fileSystem, path)
         r = font.testForExternalChanges()
         self.assertEqual(r["deletedGlyphs"], ["A"])
         del font["A"]
         font.save()
         fileSystem = openTestFontAsFileSystem(path)
         self.assertFalse(fileSystem.exists(glyphPath))
         closeTestFontAsFileSystem(fileSystem, path)
         tearDownTestFontCopy(font.path)
Example #4
0
 def test_testForExternalChanges_remove_a_layer(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         fileSystem = openTestFontAsFileSystem(path)
         fs.copy.copy_dir(fileSystem, "glyphs", fileSystem, "glyphs.test")
         with fileSystem.open(u"layercontents.plist", "rb") as f:
             contents = load(f)
         contents.append(("test", "glyphs.test"))
         with fileSystem.open(u"layercontents.plist", "wb") as f:
             dump(contents, f)
         closeTestFontAsFileSystem(fileSystem, path)
         font = Font(path)
         fileSystem = openTestFontAsFileSystem(path)
         fileSystem.removetree(u"glyphs.test")
         with fileSystem.open(u"layercontents.plist", "rb") as f:
             contents = load(f)
         del contents[-1]
         with fileSystem.open(u"layercontents.plist", "wb") as f:
             dump(contents, f)
         closeTestFontAsFileSystem(fileSystem, path)
         reader = UFOReader(path)
         self.assertEqual(font.layers.testForExternalChanges(reader)["deleted"],
                          ["test"])
         tearDownTestFontCopy(font.path)
Example #5
0
    def test_testForExternalChanges_change_default_layer(self):
        for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
            path = getTestFontPath(ufo)
            path = makeTestFontCopy(path)

            fileSystem = openTestFontAsFileSystem(path)
            fs.copy.copy_dir(fileSystem, "glyphs", fileSystem, "glyphs.test")
            contents = [("foo", "glyphs"), ("test", "glyphs.test")]
            with fileSystem.open(u"layercontents.plist", "wb") as f:
                dump(contents, f)
            closeTestFontAsFileSystem(fileSystem, path)
            font = Font(path)
            fileSystem = openTestFontAsFileSystem(path)
            contents = [("foo", "glyphs.test"), ("test", "glyphs")]
            with fileSystem.open(u"layercontents.plist", "wb") as f:
                dump(contents, f)
            closeTestFontAsFileSystem(fileSystem, path)
            reader = UFOReader(path)
            self.assertEqual(
                font.layers.testForExternalChanges(reader), {
                    "deleted": [],
                    "added": [],
                    "modified": {},
                    "defaultLayer": True,
                    "order": False
                })
            tearDownTestFontCopy(font.path)
Example #6
0
 def test_testForExternalChanges_change_layer_order(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         fileSystem = openTestFontAsFileSystem(path)
         fs.copy.copy_dir(fileSystem, "glyphs", fileSystem, "glyphs.test")
         with fileSystem.open(u"layercontents.plist", "rb") as f:
             contents = load(f)
         contents.append(("test", "glyphs.test"))
         with fileSystem.open(u"layercontents.plist", "wb") as f:
             dump(contents, f)
         closeTestFontAsFileSystem(fileSystem, path)
         with Font(path) as font:
             fileSystem = openTestFontAsFileSystem(path)
             with fileSystem.open(u"layercontents.plist", "rb") as f:
                 contents = load(f)
             contents.reverse()
             with fileSystem.open(u"layercontents.plist", "wb") as f:
                 dump(contents, f)
             closeTestFontAsFileSystem(fileSystem, path)
             with UFOReader(path) as reader:
                 self.assertEqual(font.layers.testForExternalChanges(reader),
                                  {"deleted": [], "added": [], "modified": {},
                                   "defaultLayer": False, "order": True})
         tearDownTestFontCopy(font.path)
Example #7
0
 def test_delitem_glyph_dirty(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         glyph = font["A"]
         glyph.dirty = True
         fileSystem = openTestFontAsFileSystem(path)
         glyphPath = fs.path.join("glyphs", "A_.glif")
         fileSystem.remove(glyphPath)
         contentsPath = fs.path.join("glyphs", "contents.plist")
         with fileSystem.open(contentsPath, "rb") as f:
             plist = load(f)
         del plist["A"]
         with fileSystem.open(contentsPath, "wb") as f:
             dump(plist, f)
         closeTestFontAsFileSystem(fileSystem, path)
         r = font.testForExternalChanges()
         self.assertEqual(r["deletedGlyphs"], ["A"])
         del font["A"]
         font.save()
         fileSystem = openTestFontAsFileSystem(path)
         self.assertFalse(fileSystem.exists(glyphPath))
         closeTestFontAsFileSystem(fileSystem, path)
         tearDownTestFontCopy(font.path)
Example #8
0
 def test_testExternalChanges_remove_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         fileSystem = openTestFontAsFileSystem(font.path)
         fileSystem.remove(fs.path.join("images", "image 1.png"))
         closeTestFontAsFileSystem(fileSystem, font.path)
         reader = UFOReader(path)
         self.assertEqual(font.images.testForExternalChanges(reader),
                          ([], [], ["image 1.png"]))
         tearDownTestFontCopy(font.path)
Example #9
0
 def test_testExternalChanges_remove_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         fileSystem = openTestFontAsFileSystem(font.path)
         fileSystem.remove(fs.path.join("images", "image 1.png"))
         closeTestFontAsFileSystem(fileSystem, font.path)
         reader = UFOReader(path)
         self.assertEqual(font.images.testForExternalChanges(reader),
                          ([], [], ["image 1.png"]))
         tearDownTestFontCopy(font.path)
Example #10
0
 def test_testForExternalChanges_add_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         fileSystem = openTestFontAsFileSystem(font.path)
         source = fs.path.join("data", "com.typesupply.defcon.test.file")
         dest = fs.path.join("data", "com.typesupply.defcon.test.file2")
         fileSystem.copy(source, dest)
         closeTestFontAsFileSystem(fileSystem, font.path)
         reader = UFOReader(path)
         self.assertEqual(font.data.testForExternalChanges(reader),
                          ([], ["com.typesupply.defcon.test.file2"], []))
         tearDownTestFontCopy(font.path)
Example #11
0
 def test_testForExternalChanges_add_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         fileSystem = openTestFontAsFileSystem(font.path)
         source = fs.path.join("data", "com.typesupply.defcon.test.file")
         dest = fs.path.join("data", "com.typesupply.defcon.test.file2")
         fileSystem.copy(source, dest)
         closeTestFontAsFileSystem(fileSystem, font.path)
         reader = UFOReader(path)
         self.assertEqual(font.data.testForExternalChanges(reader),
                          ([], ["com.typesupply.defcon.test.file2"], []))
         tearDownTestFontCopy(font.path)
Example #12
0
 def test_testExternalChanges_modify_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         font.images["image 1.png"]  # image = font.images["image 1.png"]
         fileSystem = openTestFontAsFileSystem(font.path)
         imagePath = fs.path.join("images", "image 1.png")
         data = fileSystem.getbytes(imagePath)
         fileSystem.setbytes(imagePath, data + b"blah")
         closeTestFontAsFileSystem(fileSystem, font.path)
         reader = UFOReader(path)
         self.assertEqual(font.images.testForExternalChanges(reader),
                          (["image 1.png"], [], []))
         tearDownTestFontCopy(font.path)
Example #13
0
 def test_testExternalChanges_modify_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         font.images["image 1.png"]  # image = font.images["image 1.png"]
         fileSystem = openTestFontAsFileSystem(font.path)
         imagePath = fs.path.join("images", "image 1.png")
         data = fileSystem.getbytes(imagePath)
         fileSystem.setbytes(imagePath, data + b"blah")
         closeTestFontAsFileSystem(fileSystem, font.path)
         reader = UFOReader(path)
         self.assertEqual(font.images.testForExternalChanges(reader),
                          (["image 1.png"], [], []))
         tearDownTestFontCopy(font.path)
Example #14
0
 def test_testExternalChanges_add_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         with Font(path) as font:
             fileSystem = openTestFontAsFileSystem(font.path)
             source = fs.path.join("images", "image 1.png")
             dest = fs.path.join("images", "image 3.png")
             fileSystem.copy(source, dest)
             closeTestFontAsFileSystem(fileSystem, font.path)
             with UFOReader(path) as reader:
                 self.assertEqual(
                     font.images.testForExternalChanges(reader),
                     ([], ["image 3.png"], []))
         tearDownTestFontCopy(font.path)
Example #15
0
 def test_testForExternalChanges_modify_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         # d = font.data["com.typesupply.defcon.test.file"]
         font.data["com.typesupply.defcon.test.file"]
         fileSystem = openTestFontAsFileSystem(font.path)
         filePath = fs.path.join("data", "com.typesupply.defcon.test.file")
         fileSystem.setbytes(filePath, b"blah")
         closeTestFontAsFileSystem(fileSystem, font.path)
         reader = UFOReader(path)
         self.assertEqual(font.data.testForExternalChanges(reader),
                          (["com.typesupply.defcon.test.file"], [], []))
         tearDownTestFontCopy(font.path)
Example #16
0
 def test_testForExternalChanges_remove_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         with Font(path) as font:
             # image = font.data["com.typesupply.defcon.test.file"]
             font.data["com.typesupply.defcon.test.file"]
             fileSystem = openTestFontAsFileSystem(font.path)
             fileSystem.remove(
                 fs.path.join("data", "com.typesupply.defcon.test.file"))
             closeTestFontAsFileSystem(fileSystem, font.path)
             with UFOReader(path) as reader:
                 self.assertEqual(
                     font.data.testForExternalChanges(reader),
                     ([], [], ["com.typesupply.defcon.test.file"]))
         tearDownTestFontCopy(font.path)
Example #17
0
 def test_testForExternalChanges_modify_on_disk_and_scan(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         # d = font.data["com.typesupply.defcon.test.file"]
         font.data["com.typesupply.defcon.test.file"]
         fileSystem = openTestFontAsFileSystem(font.path)
         filePath = fs.path.join("data",
                                 "com.typesupply.defcon.test.file")
         fileSystem.setbytes(filePath, b"blah")
         closeTestFontAsFileSystem(fileSystem, font.path)
         reader = UFOReader(path)
         self.assertEqual(font.data.testForExternalChanges(reader),
                          (["com.typesupply.defcon.test.file"], [], []))
         tearDownTestFontCopy(font.path)
Example #18
0
 def test_testForExternalChanges_layerinfo(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         # layerinfo.plist
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         data = {"lib": {}}
         data["lib"]["testForExternalChanges.test"] = 1
         fileSystem = openTestFontAsFileSystem(path)
         p = fs.path.join("glyphs", "layerinfo.plist")
         with fileSystem.open(p, mode="wb") as f:
             dump(data, f)
         closeTestFontAsFileSystem(fileSystem, path)
         reader = UFOReader(path)
         self.assertTrue(
             font.layers.testForExternalChanges(reader)
             ["modified"]["public.default"]["info"])
         tearDownTestFontCopy(font.path)
Example #19
0
 def test_testForExternalChanges_layerinfo(self):
     for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
         # layerinfo.plist
         path = getTestFontPath(ufo)
         path = makeTestFontCopy(path)
         font = Font(path)
         data = {"lib": {}}
         data["lib"]["testForExternalChanges.test"] = 1
         fileSystem = openTestFontAsFileSystem(path)
         p = fs.path.join("glyphs", "layerinfo.plist")
         with fileSystem.open(p, mode="wb") as f:
             dump(data, f)
         closeTestFontAsFileSystem(fileSystem, path)
         reader = UFOReader(path)
         self.assertTrue(
             font.layers.testForExternalChanges(reader)["modified"]
             ["public.default"]["info"])
         tearDownTestFontCopy(font.path)
Example #20
0
    def test_testForExternalChanges(self):
        for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
            path = getTestFontPath(ufo)
            path = makeTestFontCopy(path)
            font = Font(path)

            # load all the objects so that they get stamped
            font.info  # i = font.info
            k = font.kerning
            font.groups  # g = font.groups
            font.lib  # l = font.lib
            font["A"]  # g = font["A"]

            d = font.testForExternalChanges()
            self.assertFalse(d["info"])
            self.assertFalse(d["kerning"])
            self.assertFalse(d["groups"])
            self.assertFalse(d["lib"])

            # make a simple change to the kerning data
            fileSystem = openTestFontAsFileSystem(font.path)
            path = u"kerning.plist"
            t = fileSystem.getbytes(path)
            t += b"<!-- test -->"
            fileSystem.setbytes(path, t)
            k._dataOnDiskTimeStamp -= 1
            closeTestFontAsFileSystem(fileSystem, font.path)

            d = font.testForExternalChanges()
            self.assertTrue(d["kerning"])
            self.assertFalse(d["groups"])
            self.assertFalse(d["info"])
            self.assertFalse(d["lib"])

            # save the kerning data and test again
            font.kerning.dirty = True
            font.save()
            d = font.testForExternalChanges()
            self.assertFalse(d["kerning"])
            self.assertFalse(d["groups"])
            self.assertFalse(d["info"])
            self.assertFalse(d["lib"])

            tearDownTestFontCopy(font.path)
Example #21
0
    def test_testForExternalChanges(self):
        for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
            path = getTestFontPath(ufo)
            path = makeTestFontCopy(path)
            font = Font(path)

            # load all the objects so that they get stamped
            font.info  # i = font.info
            k = font.kerning
            font.groups  # g = font.groups
            font.lib  # l = font.lib
            font["A"]  # g = font["A"]

            d = font.testForExternalChanges()
            self.assertFalse(d["info"])
            self.assertFalse(d["kerning"])
            self.assertFalse(d["groups"])
            self.assertFalse(d["lib"])

            # make a simple change to the kerning data
            fileSystem = openTestFontAsFileSystem(font.path)
            path = u"kerning.plist"
            t = fileSystem.getbytes(path)
            t += b"<!-- test -->"
            fileSystem.setbytes(path, t)
            k._dataOnDiskTimeStamp -= 1
            closeTestFontAsFileSystem(fileSystem, font.path)

            d = font.testForExternalChanges()
            self.assertTrue(d["kerning"])
            self.assertFalse(d["groups"])
            self.assertFalse(d["info"])
            self.assertFalse(d["lib"])

            # save the kerning data and test again
            font.kerning.dirty = True
            font.save()
            d = font.testForExternalChanges()
            self.assertFalse(d["kerning"])
            self.assertFalse(d["groups"])
            self.assertFalse(d["info"])
            self.assertFalse(d["lib"])

            tearDownTestFontCopy(font.path)
Example #22
0
    def test_testForExternalChanges(self):
        for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
            path = getTestFontPath(ufo)
            path = makeTestFontCopy(path)
            try:
                font = Font(path)

                reader = UFOReader(font.path)
                self.assertEqual(
                    font.layers[None].testForExternalChanges(reader),
                    ([], [], []))

                # make a simple change to a glyph
                fileSystem = openTestFontAsFileSystem(font.path)
                g = font.layers[None]["A"]
                path = fs.path.join("glyphs", "A_.glif")
                t = fileSystem.getbytes(path)
                t += b"<!-- test -->"
                fileSystem.setbytes(path, t)
                g._dataOnDiskTimeStamp -= 1
                closeTestFontAsFileSystem(fileSystem, font.path)
                reader = UFOReader(font.path)
                self.assertEqual(
                    font.layers[None].testForExternalChanges(reader),
                    (["A"], [], []))

                # save the glyph and test again
                font["A"].dirty = True
                font.save()
                reader = UFOReader(font.path)
                self.assertEqual(
                    font.layers[None].testForExternalChanges(reader),
                    ([], [], []))

                # add a glyph
                fileSystem = openTestFontAsFileSystem(font.path)
                path = fs.path.join("glyphs", "A_.glif")
                t = fileSystem.getbytes(path)
                t = t.replace(b'<glyph name="A" format="1">',
                              b'<glyph name="XYZ" format="1">')
                path = fs.path.join("glyphs", "XYZ.glif")
                fileSystem.setbytes(path, t)
                path = fs.path.join("glyphs", "contents.plist")
                with fileSystem.open(path, "rb") as f:
                    plist = load(f)
                savePlist = dict(plist)
                plist["XYZ"] = "XYZ.glif"
                with fileSystem.open(path, "wb") as f:
                    dump(plist, f)
                closeTestFontAsFileSystem(fileSystem, font.path)
                reader = UFOReader(font.path)
                self.assertEqual(
                    font.layers[None].testForExternalChanges(reader),
                    ([], ["XYZ"], []))
                path = font.path

                # delete a glyph
                font = Font(path)
                g = font["XYZ"]
                fileSystem = openTestFontAsFileSystem(font.path)
                path = fs.path.join("glyphs", "contents.plist")
                with fileSystem.open(path, "wb") as f:
                    dump(savePlist, f)
                path = fs.path.join("glyphs", "XYZ.glif")
                fileSystem.remove(path)
                closeTestFontAsFileSystem(fileSystem, font.path)
                reader = UFOReader(font.path)
                self.assertEqual(
                    font.layers[None].testForExternalChanges(reader),
                    ([], [], ["XYZ"]))
            finally:
                tearDownTestFontCopy(font.path)
Example #23
0
    def test_testForExternalChanges(self):
        for ufo in (u"TestExternalEditing.ufo", u"TestExternalEditing.ufoz"):
            path = getTestFontPath(ufo)
            path = makeTestFontCopy(path)
            try:
                font = Font(path)

                reader = UFOReader(font.path)
                self.assertEqual(font.layers[None].testForExternalChanges(reader),
                                 ([], [], []))

                # make a simple change to a glyph
                fileSystem = openTestFontAsFileSystem(font.path)
                g = font.layers[None]["A"]
                path = fs.path.join("glyphs", "A_.glif")
                t = fileSystem.getbytes(path)
                t += b"<!-- test -->"
                fileSystem.setbytes(path, t)
                g._dataOnDiskTimeStamp -= 1
                closeTestFontAsFileSystem(fileSystem, font.path)
                reader = UFOReader(font.path)
                self.assertEqual(font.layers[None].testForExternalChanges(reader),
                                 (["A"], [], []))

                # save the glyph and test again
                font["A"].dirty = True
                font.save()
                reader = UFOReader(font.path)
                self.assertEqual(font.layers[None].testForExternalChanges(reader),
                                 ([], [], []))

                # add a glyph
                fileSystem = openTestFontAsFileSystem(font.path)
                path = fs.path.join("glyphs", "A_.glif")
                t = fileSystem.getbytes(path)
                t = t.replace(b'<glyph name="A" format="1">',
                              b'<glyph name="XYZ" format="1">')
                path = fs.path.join("glyphs", "XYZ.glif")
                fileSystem.setbytes(path, t)
                path = fs.path.join("glyphs", "contents.plist")
                with fileSystem.open(path, "rb") as f:
                    plist = load(f)
                savePlist = dict(plist)
                plist["XYZ"] = "XYZ.glif"
                with fileSystem.open(path, "wb") as f:
                    dump(plist, f)
                closeTestFontAsFileSystem(fileSystem, font.path)
                reader = UFOReader(font.path)
                self.assertEqual(font.layers[None].testForExternalChanges(reader),
                                 ([], ["XYZ"], []))
                path = font.path

                # delete a glyph
                font = Font(path)
                g = font["XYZ"]
                fileSystem = openTestFontAsFileSystem(font.path)
                path = fs.path.join("glyphs", "contents.plist")
                with fileSystem.open(path, "wb") as f:
                    dump(savePlist, f)
                path = fs.path.join("glyphs", "XYZ.glif")
                fileSystem.remove(path)
                closeTestFontAsFileSystem(fileSystem, font.path)
                reader = UFOReader(font.path)
                self.assertEqual(font.layers[None].testForExternalChanges(reader),
                                 ([], [], ["XYZ"]))
            finally:
                tearDownTestFontCopy(font.path)