@@ -49,39 +49,41 @@ def test_core_search(run_command, httpserver):
4949 result = run_command (f"core search retrokit --all --additional-urls={ url } " )
5050 assert result .ok
5151 lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
52- assert 11 == len (lines )
5352 assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
5453 assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
5554 assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
5655 assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
56+ header_index = lines .index (["ID" , "Version" , "Name" ])
57+ assert 2 == len (lines [header_index + 1 :]) # noqa: E203
5758
5859 # Search using Retrokit Package Maintainer
5960 result = run_command (f"core search Retrokits-RK002 --all --additional-urls={ url } " )
6061 assert result .ok
6162 lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
62- assert 11 == len (lines )
6363 assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
6464 assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
6565 assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
6666 assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
67+ assert 2 == len (lines [header_index + 1 :]) # noqa: E203
6768
6869 # Search using the Retrokit Platform name
6970 result = run_command (f"core search rk002 --all --additional-urls={ url } " )
7071 assert result .ok
71- assert 11 == len ( lines )
72+ lines = [ l . strip (). split () for l in result . stdout . strip (). splitlines ()]
7273 assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
7374 assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
7475 assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
7576 assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
77+ assert 2 == len (lines [header_index + 1 :]) # noqa: E203
7678
7779 # Search using a board name
7880 result = run_command (f"core search myboard --all --additional-urls={ url } " )
7981 assert result .ok
80- assert 10 == len (result .stdout .strip ().splitlines ())
8182 lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
8283 assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
8384 assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
8485 assert ["Package:x86" , "1.2.3" , "Platform" ] in lines
86+ assert 1 == len (lines [header_index + 1 :]) # noqa: E203
8587
8688
8789def test_core_search_no_args (run_command , httpserver ):
@@ -104,11 +106,11 @@ def test_core_search_no_args(run_command, httpserver):
104106 num_platforms = 0
105107 lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
106108 # Index update output and the header are printed on the first lines
107- assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines [: 6 ]
108- assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines [: 6 ]
109- assert ["ID " , "Version " , "Name " ] == lines [ 5 ]
110- assert [ "test:x86 " , "2.0.0 " , "test_core" ] in lines [ 6 :]
111- num_platforms = len (lines [6 :])
109+ assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
110+ assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
111+ assert ["test:x86 " , "2.0.0 " , "test_core " ] in lines
112+ header_index = lines . index ([ "ID " , "Version " , "Name" ])
113+ num_platforms = len (lines [header_index + 1 :]) # noqa: E203
112114
113115 # same thing in JSON format, also check the number of platforms found is the same
114116 result = run_command ("core search --format json" )
@@ -123,11 +125,11 @@ def test_core_search_no_args(run_command, httpserver):
123125 num_platforms = 0
124126 lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
125127 # Index update output and the header are printed on the first lines
126- assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines [: 9 ]
127- assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines [: 9 ]
128- assert ["ID " , "Version " , "Name " ] == lines [ 8 ]
129- assert [ "test:x86 " , "2.0.0 " , "test_core" ] in lines [ 9 :]
130- num_platforms = len (lines [9 :])
128+ assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
129+ assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
130+ assert ["test:x86 " , "2.0.0 " , "test_core " ] in lines
131+ header_index = lines . index ([ "ID " , "Version " , "Name" ])
132+ num_platforms = len (lines [header_index + 1 :]) # noqa: E203
131133
132134 # same thing in JSON format, also check the number of platforms found is the same
133135 result = run_command (f"core search --format json --additional-urls={ url } " )
0 commit comments