예제 #1
0
 def test_plot_needed(self, exec_plot_mock, sys_mock):
     args = MagicMock()
     sys_mock.exit = MagicMock()
     cmd = 'df.plot(x="a", y="b")'
     process_command(args, cmd, self.df)
     self.assertTrue(exec_plot_mock.called)
     self.assertTrue(sys_mock.exit.called)
예제 #2
0
    def test_regular_command(self):
        args = MagicMock()
        cmd = 'df.a.value_counts()'
        df = process_command(args, cmd, self.df)

        # this line is needed so tests pass for different pandas version
        df = df.rename(columns={0: 'a'})

        self.assertEqual(set(df.index), {1, 2, 3, 4})
        self.assertEqual(set(df['a']), {1})
예제 #3
0
 def test_regular_command(self):
     args = MagicMock()
     cmd = 'df.a.value_counts()'
     df = process_command(args, cmd, self.df)
     self.assertEqual(set(df.index), {1, 2, 3, 4})
     self.assertEqual(set(df[0]), {1})
예제 #4
0
 def test_col_assignement(self):
     args = MagicMock()
     cmd = 'df["c"] = 2 * df["a"]'
     df = process_command(args, cmd, self.df)
     self.assertEqual(df.c.iloc[0], 2)
예제 #5
0
 def test_regular_command(self):
     args = MagicMock()
     cmd = 'df.a.value_counts()'
     df = process_command(args, cmd, self.df)
     self.assertEqual(set(df.index), {1, 2, 3, 4})
     self.assertEqual(set(df[0]), {1})