aboutsummaryrefslogtreecommitdiff
path: root/tests/test_alt.py
blob: 4d4c4a9dba89c0b81b74a3f3478bb470043a11b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import unittest
import dialoguer
import rpy2.robjects as robjects
from rpy2.robjects.packages import importr


class TestAlt(unittest.TestCase):

	# @classmethod
	# def setUpClass(cls):
	# 	source_file_path = __file__.replace('.py', '.r')
	# 	cls.src_fil_r = dialoguer.Dialogue(source_file_path)

	# @classmethod
	# def tearDownClass(cls):
	# 	cls.src_fil_r.close()

	# def setUp(self):
	# 	source_file_path = __file__.replace('.py', '.r')
	# 	self.src_fil_r = dialoguer.Dialogue(source_file_path)

	# def tearDown(self):
	# 	self.src_fil_r.close()

	def test_integer(self):
		source_file_path = __file__.replace('.py', '.r')
		src_fil_r = dialoguer.Dialogue(source_file_path)
		for i in range(50000):
			src_fil_r.assign_variable('int_i', i)
			chk_i = src_fil_r.import_variable('int_i')
			self.assertEqual(chk_i, i)
		src_fil_r.close()

	def test_integer_alt(self):
		for i in range(50000):
			robjects.r(f'int_i <- {i}')    
			chk_i = int(robjects.r['int_i'][0])
			#chk_i = int(chk_i[0])
			self.assertEqual(chk_i, i)


if __name__ == '__main__':
	unittest.main()