@@ -21,16 +21,32 @@ interface DependencyInfo {
21
21
directDeps : string [ ] ;
22
22
}
23
23
24
+ // This function is a helper to return the version a dependency gets resolved to in the graph
25
+ // (in case we aren't able to determine it). This is useful for transitive dependencies
26
+ // where the latest version of the package gets pulled in by a top level dependency.
27
+ // This latest version can vary between python version and is not consistent for testing with `compareTransitiveLines`
28
+ function getGraphPkg (
29
+ graph : depGraphLib . DepGraph ,
30
+ depInfo : DependencyInfo
31
+ ) : depGraphLib . Pkg {
32
+ const pkgs = graph . getPkgs ( ) ;
33
+ if ( depInfo . pkg . version ) {
34
+ return depInfo . pkg ;
35
+ }
36
+ return pkgs . filter ( ( pkg ) => pkg . name == depInfo . pkg . name ) [ 0 ] ;
37
+ }
38
+
24
39
// We can't do a full dependency graph comparison, as generated dependency graphs vary wildly
25
40
// between Python versions. Instead, we ensure that the transitive lines are not broken.
26
41
function compareTransitiveLines (
27
42
received : depGraphLib . DepGraph ,
28
43
expected : DependencyInfo [ ]
29
44
) {
30
45
expected . forEach ( ( depInfo : DependencyInfo ) => {
31
- expect (
32
- received . directDepsLeadingTo ( depInfo . pkg ) . map ( ( pkg ) => pkg . name )
33
- ) . toEqual ( depInfo . directDeps ) ;
46
+ const pkg = getGraphPkg ( received , depInfo ) ;
47
+ expect ( received . directDepsLeadingTo ( pkg ) . map ( ( pkg ) => pkg . name ) ) . toEqual (
48
+ depInfo . directDeps
49
+ ) ;
34
50
} ) ;
35
51
}
36
52
@@ -100,7 +116,7 @@ describe('inspect', () => {
100
116
{
101
117
pkg : {
102
118
name : 'jaraco.collections' ,
103
- version : '5.0.1 ' ,
119
+ version : '5.1.0 ' ,
104
120
} ,
105
121
directDeps : [ 'irc' ] ,
106
122
} ,
@@ -121,7 +137,6 @@ describe('inspect', () => {
121
137
{
122
138
pkg : {
123
139
name : 'markupsafe' ,
124
- version : '2.1.5' ,
125
140
} ,
126
141
directDeps : [ 'jinja2' ] ,
127
142
} ,
@@ -135,7 +150,6 @@ describe('inspect', () => {
135
150
{
136
151
pkg : {
137
152
name : 'markupsafe' ,
138
- version : '2.1.5' ,
139
153
} ,
140
154
directDeps : [ 'jinja2' ] ,
141
155
} ,
@@ -163,7 +177,7 @@ describe('inspect', () => {
163
177
{
164
178
pkg : {
165
179
name : 's3transfer' ,
166
- version : '0.10.2 ' ,
180
+ version : '0.10.4 ' ,
167
181
} ,
168
182
directDeps : [ 'awss' ] ,
169
183
} ,
@@ -177,7 +191,6 @@ describe('inspect', () => {
177
191
{
178
192
pkg : {
179
193
name : 'markupsafe' ,
180
- version : '2.1.5' ,
181
194
} ,
182
195
directDeps : [ 'jinja2' ] ,
183
196
} ,
@@ -314,7 +327,7 @@ describe('inspect', () => {
314
327
{
315
328
pkg : {
316
329
name : 'jaraco.collections' ,
317
- version : '5.0.1 ' ,
330
+ version : '5.1.0 ' ,
318
331
} ,
319
332
directDeps : [ 'irc' ] ,
320
333
} ,
@@ -335,7 +348,6 @@ describe('inspect', () => {
335
348
{
336
349
pkg : {
337
350
name : 'markupsafe' ,
338
- version : '2.1.5' ,
339
351
} ,
340
352
directDeps : [ 'jinja2' ] ,
341
353
} ,
@@ -349,7 +361,6 @@ describe('inspect', () => {
349
361
{
350
362
pkg : {
351
363
name : 'markupsafe' ,
352
- version : '2.1.5' ,
353
364
} ,
354
365
directDeps : [ 'jinja2' ] ,
355
366
} ,
@@ -377,7 +388,7 @@ describe('inspect', () => {
377
388
{
378
389
pkg : {
379
390
name : 's3transfer' ,
380
- version : '0.10.2 ' ,
391
+ version : '0.10.4 ' ,
381
392
} ,
382
393
directDeps : [ 'awss' ] ,
383
394
} ,
@@ -391,7 +402,6 @@ describe('inspect', () => {
391
402
{
392
403
pkg : {
393
404
name : 'markupsafe' ,
394
- version : '2.1.5' ,
395
405
} ,
396
406
directDeps : [ 'jinja2' ] ,
397
407
} ,
@@ -698,7 +708,6 @@ describe('inspect', () => {
698
708
{
699
709
pkg : {
700
710
name : 'markupsafe' ,
701
- version : '2.1.5' ,
702
711
} ,
703
712
directDeps : [ 'jinja2' ] ,
704
713
} ,
@@ -750,7 +759,6 @@ describe('inspect', () => {
750
759
{
751
760
pkg : {
752
761
name : 'markupsafe' ,
753
- version : '2.1.5' ,
754
762
} ,
755
763
directDeps : [ 'jinja2' ] ,
756
764
} ,
0 commit comments