File tree 2 files changed +57
-1
lines changed 2 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 17
17
test :
18
18
19
19
runs-on : " ubuntu-latest"
20
+
21
+ services :
22
+
23
+ cratedb :
24
+ image : crate:5.1.1
25
+ ports :
26
+ - 4200:4200
27
+
20
28
steps :
21
29
22
30
- name : Acquire sources
30
38
31
39
- name : Install dependencies
32
40
run : |
33
- pip install pytest
41
+ pip install pytest crate[sqlalchemy]
34
42
35
43
- name : Run tests
36
44
run : |
Original file line number Diff line number Diff line change
1
+ """
2
+ Evaluate CodeQL scan false positive with `py/unused-local-variable`.
3
+
4
+ Synopsis::
5
+
6
+ pip install pytest crate[sqlalchemy]
7
+ docker run --rm -it --publish=4200:4200 crate:5.1.1
8
+ pytest unused-local-variable.py
9
+ """
10
+ from unittest .mock import MagicMock , patch
11
+
12
+ import pytest
13
+ import sqlalchemy as sa
14
+ from crate .client .cursor import Cursor
15
+ from sqlalchemy .orm import declarative_base
16
+
17
+ pytest .skip (reason = "Implementation incomplete" , allow_module_level = True )
18
+
19
+
20
+ fake_cursor = MagicMock (name = "fake_cursor" )
21
+ FakeCursor = MagicMock (name = "FakeCursor" , spec = Cursor )
22
+ FakeCursor .return_value = fake_cursor
23
+
24
+
25
+ class DbWrapper :
26
+ def __init__ (self ):
27
+ self .engine = sa .create_engine ("crate://" )
28
+ self .Base = declarative_base (bind = self .engine )
29
+
30
+
31
+ @pytest .fixture
32
+ def db ():
33
+ return DbWrapper ()
34
+
35
+
36
+ @patch ("crate.client.connection.Cursor" , FakeCursor )
37
+ def test_table_with_object_array (db ):
38
+
39
+ db .Base .metadata .create_all ()
40
+ fake_cursor .execute .assert_called_with (
41
+ (
42
+ "\n CREATE TABLE t (\n \t "
43
+ "pk STRING, \n \t "
44
+ "tags ARRAY(OBJECT), \n \t "
45
+ "PRIMARY KEY (pk)\n )\n \n "
46
+ ),
47
+ (),
48
+ )
You can’t perform that action at this time.
0 commit comments