def testSelectorWidget(self): w = QgsNumericFormatSelectorWidget() spy = QSignalSpy(w.changed) # should default to a default format self.assertIsInstance(w.format(), QgsFallbackNumericFormat) w.setFormat(QgsBearingNumericFormat()) self.assertIsInstance(w.format(), QgsBearingNumericFormat) self.assertEqual(len(spy), 1) w.setFormat(QgsBearingNumericFormat()) self.assertEqual(len(spy), 2) w.setFormat(QgsCurrencyNumericFormat()) self.assertIsInstance(w.format(), QgsCurrencyNumericFormat) self.assertEqual(len(spy), 3) QgsApplication.numericFormatRegistry().addFormat(TestFormat()) QgsGui.numericFormatGuiRegistry().addFormatConfigurationWidgetFactory( 'test', TestWidgetFactory()) original = TestFormat() original.xx = 55 w = QgsNumericFormatSelectorWidget() w.setFormat(original) new = w.format() self.assertEqual(new.xx, 55)