def test_convert_backup(): """Converting produces a backup""" fname = os.path.join(self.tempdir, "idempotency.py") with open(fname, "w") as f: f.write("") from Qt import QtCompat os.chdir(self.tempdir) QtCompat._cli(args=["--convert", "idempotency.py"]) assert os.path.exists( os.path.join(self.tempdir, "%s_backup%s" % os.path.splitext(fname)))
def test_convert_backup(): """Converting produces a backup""" fname = os.path.join(self.tempdir, "idempotency.py") with open(fname, "w") as f: f.write("") from Qt import QtCompat os.chdir(self.tempdir) QtCompat._cli(args=["--convert", "idempotency.py"]) assert os.path.exists( os.path.join(self.tempdir, "%s_backup%s" % os.path.splitext(fname)) )
def test_convert_idempotency(): """Converting a converted file produces an identical file""" before = """\ from PySide2 import QtCore, QtGui, QtWidgets class Ui_uic(object): def setupUi(self, uic): self.retranslateUi(uic) def retranslateUi(self, uic): self.pushButton_2.setText( QtWidgets.QApplication.translate("uic", "NOT Ok", None, -1)) """ after = """\ from Qt import QtCompat, QtCore, QtGui, QtWidgets class Ui_uic(object): def setupUi(self, uic): self.retranslateUi(uic) def retranslateUi(self, uic): self.pushButton_2.setText( QtCompat.translate("uic", "NOT Ok", None, -1)) """ fname = os.path.join(self.tempdir, "idempotency.py") with open(fname, "w") as f: f.write(before) from Qt import QtCompat os.chdir(self.tempdir) QtCompat._cli(args=["--convert", "idempotency.py"]) with open(fname) as f: assert f.read() == after QtCompat._cli(args=["--convert", "idempotency.py"]) with open(fname) as f: assert f.read() == after