1
+ import { codeBlock } from 'common-tags' ;
1
2
import upath from 'upath' ;
2
3
import { GlobalConfig } from '../../../config/global' ;
3
4
import type { RepoGlobalConfig } from '../../../config/types' ;
@@ -36,8 +37,8 @@ describe('modules/manager/pip-compile/extract', () => {
36
37
} ) ;
37
38
38
39
describe ( 'extractPackageFile()' , ( ) => {
39
- it ( 'returns object for requirements.in' , ( ) => {
40
- const packageFile = extractPackageFile (
40
+ it ( 'returns object for requirements.in' , async ( ) => {
41
+ const packageFile = await extractPackageFile (
41
42
Fixtures . get ( 'requirementsWithHashes.txt' ) ,
42
43
'requirements.in' ,
43
44
{ } ,
@@ -46,8 +47,8 @@ describe('modules/manager/pip-compile/extract', () => {
46
47
expect ( packageFile ?. deps [ 0 ] ) . toHaveProperty ( 'depName' , 'attrs' ) ;
47
48
} ) ;
48
49
49
- it ( 'returns object for setup.py' , ( ) => {
50
- const packageFile = extractPackageFile (
50
+ it ( 'returns object for setup.py' , async ( ) => {
51
+ const packageFile = await extractPackageFile (
51
52
Fixtures . get ( 'setup.py' , '../pip_setup' ) ,
52
53
'lib/setup.py' ,
53
54
{ } ,
@@ -56,15 +57,47 @@ describe('modules/manager/pip-compile/extract', () => {
56
57
expect ( packageFile ?. deps [ 0 ] ) . toHaveProperty ( 'depName' , 'celery' ) ;
57
58
} ) ;
58
59
60
+ it ( 'returns object for pyproject.toml' , async ( ) => {
61
+ const pyproject = codeBlock `
62
+ [build-system]
63
+ requires = ["setuptools", "wheel"]
64
+ build-backend = "setuptools.build_meta"
65
+
66
+ [project]
67
+ name = "test-project"
68
+ requires-python = ">=3.11"
69
+ version = "1.2.3"
70
+ description = "Test project for pip-compile with setuptools"
71
+ readme = "README.md"
72
+ dependencies = [
73
+ "aiohttp",
74
+ "pydantic>=2.0.0",
75
+ ]
76
+
77
+ [project.optional-dependencies]
78
+ dev = [
79
+ "black",
80
+ "flake8",
81
+ ]
82
+ ` ;
83
+ const packageFile = await extractPackageFile (
84
+ pyproject ,
85
+ 'pyproject.toml' ,
86
+ { } ,
87
+ ) ;
88
+ expect ( packageFile ) . toHaveProperty ( 'deps' ) ;
89
+ expect ( packageFile ?. deps [ 0 ] ) . toHaveProperty ( 'depType' , 'requires-python' ) ;
90
+ expect ( packageFile ?. deps [ 1 ] ) . toHaveProperty ( 'depName' , 'aiohttp' ) ;
91
+ } ) ;
92
+
59
93
it . each ( [
60
94
'random.py' ,
61
95
'app.cfg' ,
62
96
'already_locked.txt' ,
63
97
// TODO(not7cd)
64
- 'pyproject.toml' ,
65
98
'setup.cfg' ,
66
- ] ) ( 'returns null on not supported package files' , ( file : string ) => {
67
- expect ( extractPackageFile ( 'some content' , file , { } ) ) . toBeNull ( ) ;
99
+ ] ) ( 'returns null on not supported package files' , async ( file : string ) => {
100
+ expect ( await extractPackageFile ( 'some content' , file , { } ) ) . toBeNull ( ) ;
68
101
} ) ;
69
102
} ) ;
70
103
0 commit comments