Example #1
0
    def test_run_dir_subconfig_valid(self, mock_print):
        config = deepcopy(CONFIG)
        config["after_imports_new_lines"] = 1

        config_file = self.test_data / IMPORTANIZE_JSON_CONFIG
        config_file.write_text(force_text(json.dumps(config)))

        try:
            consume(
                run(
                    self.test_data,
                    Config(CONFIG),
                    mock.Mock(
                        formatter="grouped",
                        ci=False,
                        print=True,
                        header=False,
                        subconfig=True,
                        length=None,
                        list=False,
                    ),
                )
            )

            mock_print.assert_has_calls(
                [mock.call(self.output_grouped_single_line)]
            )

        finally:
            config_file.unlink()
Example #2
0
    def test_run_dir_subconfig_valid(self, mock_print):
        config = deepcopy(CONFIG)
        config['after_imports_new_lines'] = 1

        config_file = self.test_data / IMPORTANIZE_CONFIG
        config_file.write_text(force_text(json.dumps(config)))

        try:
            actual = run(
                self.test_data,
                Config(CONFIG),
                mock.Mock(formatter='grouped',
                          ci=False,
                          print=True,
                          header=False,
                          subconfig=True),
            )

            self.assertIsNone(actual)
            mock_print.assert_has_calls([
                mock.call(self.output_grouped_single_line),
            ])

        finally:
            config_file.unlink()
Example #3
0
 def test_force_text(self):
     self.assertEqual(force_text(b"foo"), "foo")
     self.assertEqual(force_text("foo"), "foo")
Example #4
0
 def test_force_text(self):
     self.assertEqual(force_text(b'foo'), u'foo')
     self.assertEqual(force_text(u'foo'), u'foo')
Example #5
0
def test_force_text() -> None:
    assert force_text(b"foo") == "foo"
    assert force_text("foo") == "foo"