'use strict'

const { platform } = require('os')
const { resolve } = require('path')
const { URL } = require('url')
const fetch = require('node-fetch')
const Serverless = require('serverless')
const ServerlessOffline = require('../../../src/ServerlessOffline.js')
const { detectPython3 } = require('../../../src/utils/index.js')

jest.setTimeout(60000)

describe('Python 3 tests', () => {
  let serverlessOffline

  if (platform() === 'win32') {
    it.only("skipping 'Python' tests on Windows for now.", () => {})
  }

  if (!detectPython3()) {
    it.only("Could not find 'Python 3' executable, skipping 'Python' tests.", () => {})
  }

  // init
  beforeAll(async () => {
    const serverless = new Serverless({
      servicePath: resolve(__dirname),
    })
    await serverless.init()
    serverless.processedInput.commands = ['offline', 'start']
    await serverless.run()
    serverlessOffline = new ServerlessOffline(serverless, {})

    return serverlessOffline.start()
  })

  // cleanup
  afterAll(async () => {
    return serverlessOffline.end()
  })

  const url = new URL('http://localhost:3000')

  ;[
    {
      description: 'should work with python 3',
      expected: {
        message: 'Hello Python 3!',
      },
      path: 'hello',
    },
  ].forEach(({ description, expected, path }) => {
    test(description, async () => {
      url.pathname = path
      const response = await fetch(url)
      const json = await response.json()
      expect(json).toEqual(expected)
    })
  })
})

@@ -323,16 +323,66 @@
 x.js')%0A%0A
+const endpoint = process.env.npm_config_endpoint%0A%0A
 jest.set
@@ -714,24 +714,64 @@
 ync () =%3E %7B%0A
+    if (endpoint) %7B%0A      return%0A    %7D%0A%0A
     const se
@@ -1101,24 +1101,64 @@
 ync () =%3E %7B%0A
+    if (endpoint) %7B%0A      return%0A    %7D%0A%0A
     return s
@@ -1186,16 +1186,16 @@
 )%0A  %7D)%0A%0A
-
   const 
@@ -1208,16 +1208,28 @@
 new URL(
+endpoint %7C%7C 
 'http://

Fix python 3 test with aws endpoint