code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def testDefaultDpid( self ):
"""Verify that the default dpid is assigned using a valid provided
canonical switchname if no dpid is passed in switch creation."""
net = Mininet( Topo(), self.switchClass, Host, Controller )
switch = net.addSwitch( 's1' )
self.assertEqual( switch.def... | Verify that the default dpid is assigned using a valid provided
canonical switchname if no dpid is passed in switch creation. | testDefaultDpid | python | mininet/mininet | mininet/test/test_switchdpidassignment.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_switchdpidassignment.py | BSD-3-Clause |
def testActualDpidAssignment( self ):
"""Verify that Switch dpid is the actual dpid assigned if dpid is
passed in switch creation."""
dpid = self.dpidFrom( 0xABCD )
net = Mininet( Topo(), self.switchClass, Host, Controller )
switch = net.addSwitch( 's1', dpid=dpid )
self.... | Verify that Switch dpid is the actual dpid assigned if dpid is
passed in switch creation. | testActualDpidAssignment | python | mininet/mininet | mininet/test/test_switchdpidassignment.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_switchdpidassignment.py | BSD-3-Clause |
def testDefaultDpidAssignmentFailure( self ):
"""Verify that Default dpid assignment raises an Exception if the
name of the switch does not contain a digit. Also verify the
exception message."""
net = Mininet( Topo(), self.switchClass, Host, Controller )
with self.assertRaises( E... | Verify that Default dpid assignment raises an Exception if the
name of the switch does not contain a digit. Also verify the
exception message. | testDefaultDpidAssignmentFailure | python | mininet/mininet | mininet/test/test_switchdpidassignment.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_switchdpidassignment.py | BSD-3-Clause |
def testDefaultDpidLen( self ):
"""Verify that Default dpid length is 16 characters consisting of
16 - len(hex of first string of contiguous digits passed in switch
name) 0's followed by hex of first string of contiguous digits passed
in switch name."""
net = Mininet( Topo(), sel... | Verify that Default dpid length is 16 characters consisting of
16 - len(hex of first string of contiguous digits passed in switch
name) 0's followed by hex of first string of contiguous digits passed
in switch name. | testDefaultDpidLen | python | mininet/mininet | mininet/test/test_switchdpidassignment.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_switchdpidassignment.py | BSD-3-Clause |
def getEchoCmd( n ):
"Return a command that will print n characters"
return "echo -n " + "x" * n | Return a command that will print n characters | getEchoCmd | python | mininet/mininet | mininet/test/test_util.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_util.py | BSD-3-Clause |
def testOneRead( self ):
"""Run a command whose output is entirely read on the first call if
each call reads at most 1024 characters
"""
for n in [ 42, 1024 ]:
output = quietRun( testQuietRun.getEchoCmd( n ) )
self.assertEqual( n, len( output ) ) | Run a command whose output is entirely read on the first call if
each call reads at most 1024 characters
| testOneRead | python | mininet/mininet | mininet/test/test_util.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_util.py | BSD-3-Clause |
def testMultipleReads( self ):
"Run a command whose output is not entirely read on the first read"
for n in [ 1025, 4242 ]:
output = quietRun(testQuietRun.getEchoCmd( n ) )
self.assertEqual( n, len( output ) ) | Run a command whose output is not entirely read on the first read | testMultipleReads | python | mininet/mininet | mininet/test/test_util.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_util.py | BSD-3-Clause |
def testWireshark( self ):
"Use tshark to test the of dissector"
# Satisfy pylint
assert self
if StrictVersion( tsharkVersion() ) < StrictVersion( '1.12.0' ):
tshark = pexpect.spawn( 'tshark -i lo -R of' )
else:
tshark = pexpect.spawn( 'tshark -i lo -Y ope... | Use tshark to test the of dissector | testWireshark | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testBasic( self ):
"Test basic CLI commands (help, nodes, net, dump)"
p = pexpect.spawn( 'mn -w' )
p.expect( self.prompt )
# help command
p.sendline( 'help' )
index = p.expect( [ 'commands', self.prompt ] )
self.assertEqual( index, 0, 'No output for "help" com... | Test basic CLI commands (help, nodes, net, dump) | testBasic | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testHostCommands( self ):
"Test ifconfig and ps on h1 and s1"
p = pexpect.spawn( 'mn -w' )
p.expect( self.prompt )
# Third pattern is a local interface beginning with 'eth' or 'en'
interfaces = [ r'h1-eth0[:\s]', r's1-eth1[:\s]',
r'[^-](eth|en)\w*\d[:\s... | Test ifconfig and ps on h1 and s1 | testHostCommands | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testSimpleHTTP( self ):
"Start an HTTP server on h1 and wget from h2"
if 'Python 2' in quietRun( 'python --version' ):
httpserver = 'SimpleHTTPServer'
else:
httpserver = 'http.server'
p = pexpect.spawn( 'mn -w', logfile=stdout )
p.expect( self.prompt )... | Start an HTTP server on h1 and wget from h2 | testSimpleHTTP | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testRegressionRun( self ):
"Test pingpair (0% drop) and iperf (bw > 0) regression tests"
# test pingpair
p = pexpect.spawn( 'mn --test pingpair' )
p.expect( '0% dropped' )
p.expect( pexpect.EOF )
# test iperf
p = pexpect.spawn( 'mn --test iperf' )
p.ex... | Test pingpair (0% drop) and iperf (bw > 0) regression tests | testRegressionRun | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testTopoChange( self ):
"Test pingall on single,3 and linear,4 topos"
# testing single,3
p = pexpect.spawn( 'mn --test pingall --topo single,3' )
p.expect( r'(\d+)/(\d+) received')
received = int( p.match.group( 1 ) )
sent = int( p.match.group( 2 ) )
self.asse... | Test pingall on single,3 and linear,4 topos | testTopoChange | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testCustomTopo( self ):
"Start Mininet using a custom topo, then run pingall"
# Satisfy pylint
assert self
custom = os.path.dirname( os.path.realpath( __file__ ) )
custom = os.path.join( custom, '../../custom/topo-2sw-2host.py' )
custom = os.path.normpath( custom )
... | Start Mininet using a custom topo, then run pingall | testCustomTopo | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testStaticMAC( self ):
"Verify that MACs are set to easy to read numbers"
p = pexpect.spawn( 'mn --mac' )
p.expect( self.prompt )
for i in range( 1, 3 ):
p.sendline( 'h%d ifconfig' % i )
p.expect( r'\s00:00:00:00:00:0%d\s' % i )
p.expect( self.prom... | Verify that MACs are set to easy to read numbers | testStaticMAC | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testSwitches( self ):
"Run iperf test using user and ovsk switches"
switches = [ 'user', 'ovsk' ]
for sw in switches:
p = pexpect.spawn( 'mn --switch %s --test iperf' % sw )
p.expect( r"Results: \['([\d\.]+) .bits/sec'," )
bw = float( p.match.group( 1 ) )
... | Run iperf test using user and ovsk switches | testSwitches | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testBenchmark( self ):
"Run benchmark and verify that it takes less than 2 seconds"
p = pexpect.spawn( 'mn --test none' )
p.expect( r'completed in ([\d\.]+) seconds' )
time = float( p.match.group( 1 ) )
self.assertTrue( time < 2, 'Benchmark takes more than 2 seconds' ) | Run benchmark and verify that it takes less than 2 seconds | testBenchmark | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testOwnNamespace( self ):
"Test running user switch in its own namespace"
p = pexpect.spawn( 'mn --innamespace --switch user' )
p.expect( self.prompt )
interfaces = [ r'h1-eth0[:\s]', r's1-eth1[:\s]',
r'[^-](eth|en)\w*\d[:\s]', r'lo[:\s]',
... | Test running user switch in its own namespace | testOwnNamespace | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testPythonInterpreter( self ):
"Test py and px by checking IP for h1 and adding h3"
p = pexpect.spawn( 'mn -w' )
p.expect( self.prompt )
# test host IP
p.sendline( 'py h1.IP()' )
p.expect( '10.0.0.1' )
p.expect( self.prompt )
# test adding host
... | Test py and px by checking IP for h1 and adding h3 | testPythonInterpreter | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def testLink( self ):
"Test link CLI command using ping"
p = pexpect.spawn( 'mn -w' )
p.expect( self.prompt )
p.sendline( 'link s1 h1 down' )
p.expect( self.prompt )
p.sendline( 'h1 ping -c 1 h2' )
p.expect( 'unreachable' )
p.expect( self.prompt )
... | Test link CLI command using ping | testLink | python | mininet/mininet | mininet/test/test_walkthrough.py | https://github.com/mininet/mininet/blob/master/mininet/test/test_walkthrough.py | BSD-3-Clause |
def fixParam( line ):
"Change foo: bar to @foo bar"
result = re.sub( r'(\w+):', r'@param \1', line )
result = re.sub( r' @', r'@', result)
return result | Change foo: bar to @foo bar | fixParam | python | mininet/mininet | util/doxify.py | https://github.com/mininet/mininet/blob/master/util/doxify.py | BSD-3-Clause |
def fixReturns( line ):
"Change returns: foo to @return foo"
return re.sub( 'returns:', r'@returns', line ) | Change returns: foo to @return foo | fixReturns | python | mininet/mininet | util/doxify.py | https://github.com/mininet/mininet/blob/master/util/doxify.py | BSD-3-Clause |
def serverURL( version, arch ):
"Return .iso URL for Ubuntu version and arch"
server = 'http://cdimage.ubuntu.com/ubuntu/releases/%s/release/'
iso = 'ubuntu-%s-server-%s.iso'
return (server + iso ) % ( version, version, arch ) | Return .iso URL for Ubuntu version and arch | serverURL | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def legacyURL( version, arch ):
"Return .iso URL for Ubuntu version"
server = ( 'http://cdimage.ubuntu.com/ubuntu-legacy-server/'
'releases/%s/release/' )
iso = 'ubuntu-%s-legacy-server-%s.iso'
return (server + iso ) % ( version, version, arch ) | Return .iso URL for Ubuntu version | legacyURL | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def OSVersion( flavor ):
"Return full OS version string for build flavor"
urlbase = path.basename( isoURLs.get( flavor, 'unknown' ) )
return path.splitext( urlbase )[ 0 ] | Return full OS version string for build flavor | OSVersion | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def OVFOSNameID( flavor ):
"Return OVF-specified ( OS Name, ID ) for flavor"
version = OSVersion( flavor )
arch = archFor( flavor )
if 'ubuntu' in version:
map = { 'i386': ( 'Ubuntu', 93 ),
'x86_64': ( 'Ubuntu 64-bit', 94 ) }
else:
map = { 'i386': ( 'Linux', 36 ),
... | Return OVF-specified ( OS Name, ID ) for flavor | OVFOSNameID | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def log( *args, **kwargs ):
"""Simple log function: log( message along with local and elapsed time
cr: False/0 for no CR"""
cr = kwargs.get( 'cr', True )
elapsed = time() - LogStartTime
clocktime = strftime( '%H:%M:%S', localtime() )
msg = ' '.join( str( arg ) for arg in args )
output = '... | Simple log function: log( message along with local and elapsed time
cr: False/0 for no CR | log | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def findiso( flavor ):
"Find iso, fetching it if it's not there already"
url = isoURLs[ flavor ]
name = path.basename( url )
iso = path.join( VMImageDir, name )
if not path.exists( iso ) or ( stat( iso )[ ST_MODE ] & 0o777 != 0o444 ):
log( '* Retrieving', url )
run( 'curl -L -C - -o ... | Find iso, fetching it if it's not there already | findiso | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def attachNBD( cow, flags='' ):
"""Attempt to attach a COW disk image and return its nbd device
flags: additional flags for qemu-nbd (e.g. -r for readonly)"""
# qemu-nbd requires an absolute path
cow = abspath( cow )
log( '* Checking for unused /dev/nbdX device ' )
for i in range ( 1, 63 ):
... | Attempt to attach a COW disk image and return its nbd device
flags: additional flags for qemu-nbd (e.g. -r for readonly) | attachNBD | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def extractKernel( image, flavor, imageDir=VMImageDir ):
"Extract kernel and initrd from base image"
kernel = path.join( imageDir, flavor + '-vmlinuz' )
initrd = path.join( imageDir, flavor + '-initrd' )
log( '* Extracting kernel to', kernel )
nbd = attachNBD( image, flags='-r' )
try:
pr... | Extract kernel and initrd from base image | extractKernel | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def findBaseImage( flavor, size='8G' ):
"Return base VM image and kernel, creating them if needed"
image = path.join( VMImageDir, flavor + '-base.qcow2' )
if path.exists( image ):
# Detect race condition with multiple builds
perms = stat( image )[ ST_MODE ] & 0o777
if perms != 0o444:... | Return base VM image and kernel, creating them if needed | findBaseImage | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def makeKickstartFloppy():
"Create and return kickstart floppy, kickstart, preseed"
kickstart = 'ks.cfg'
with open( kickstart, 'w' ) as f:
f.write( KickstartText )
preseed = 'ks.preseed'
with open( preseed, 'w' ) as f:
f.write( PreseedText )
# Create floppy and copy files to it
... | Create and return kickstart floppy, kickstart, preseed | makeKickstartFloppy | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def installUbuntu( iso, image, logfilename='install.log', memory=1024 ):
"Install Ubuntu from iso onto image"
kvm = 'qemu-system-' + archFor( iso )
floppy, kickstart, preseed = makeKickstartFloppy()
# Mount iso so we can use its kernel
mnt = mkdtemp()
srun( 'mount %s %s' % ( iso, mnt ) )
for... | Install Ubuntu from iso onto image | installUbuntu | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def boot( cow, kernel, initrd, logfile, memory=1024, cpuCores=1, partnum=1 ):
"""Boot qemu/kvm with a COW disk and local/user data store
cow: COW disk path
kernel: kernel path
logfile: log file for pexpect object
memory: memory size in MB
cpuCores: number of CPU cores to use
... | Boot qemu/kvm with a COW disk and local/user data store
cow: COW disk path
kernel: kernel path
logfile: log file for pexpect object
memory: memory size in MB
cpuCores: number of CPU cores to use
returns: pexpect object to qemu process | boot | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def login( vm, user='mininet', password='mininet' ):
"Log in to vm (pexpect object)"
log( '* Waiting for login prompt' )
vm.expect( 'login: ' )
log( '* Logging in' )
vm.sendline( user )
log( '* Waiting for password prompt' )
vm.expect( 'Password: ' )
log( '* Sending password' )
vm.se... | Log in to vm (pexpect object) | login | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def removeNtpd( vm, prompt=Prompt, ntpPackage='ntp' ):
"Remove ntpd and set clock immediately"
log( '* Removing ntpd' )
vm.sendline( 'sudo -n apt-get -qy remove ' + ntpPackage )
vm.expect( prompt )
# Try to make sure that it isn't still running
vm.sendline( 'sudo -n pkill ntpd' )
vm.expect( ... | Remove ntpd and set clock immediately | removeNtpd | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def sanityTest( vm ):
"Run Mininet sanity test (pingall) in vm"
vm.sendline( 'sudo -n mn --test pingall' )
if vm.expect( [ ' 0% dropped', pexpect.TIMEOUT ], timeout=45 ) == 0:
log( '* Sanity check OK' )
else:
log( '* Sanity check FAILED' )
log( '* Sanity check output:' )
... | Run Mininet sanity test (pingall) in vm | sanityTest | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def coreTest( vm, prompt=Prompt ):
"Run core tests (make test) in VM"
log( '* Making sure cgroups are mounted' )
vm.sendline( 'sudo -n service cgroup-lite restart' )
vm.expect( prompt )
vm.sendline( 'sudo -n cgroups-mount' )
vm.expect( prompt )
log( '* Running make test' )
vm.sendline( '... | Run core tests (make test) in VM | coreTest | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def examplesfullTest( vm, prompt=Prompt ):
"Full (slow) test of mininet examples"
installPexpect( vm, prompt )
vm.sendline( 'sudo -n python ~/mininet/examples/test/runner.py -v' ) | Full (slow) test of mininet examples | examplesfullTest | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def useTest( vm, prompt=Prompt ):
"Use VM interactively - exit by pressing control-]"
old = vm.logfile
if old == stdout:
# Avoid doubling every output character!
log( '* Temporarily disabling logging to stdout' )
vm.logfile = None
log( '* Switching to interactive use - press cont... | Use VM interactively - exit by pressing control-] | useTest | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def interact( vm, tests, pre='', post='', prompt=Prompt,
clean=True):
"Interact with vm, which is a pexpect object"
login( vm )
log( '* Waiting for login...' )
vm.expect( prompt )
log( '* Sending hostname command' )
vm.sendline( 'hostname' )
log( '* Waiting for output' )
vm... | Interact with vm, which is a pexpect object | interact | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def cleanup():
"Clean up leftover qemu-nbd processes and other junk"
call( [ 'sudo', 'pkill', '-9', 'qemu-nbd' ] ) | Clean up leftover qemu-nbd processes and other junk | cleanup | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def convert( cow, basename ):
"""Convert a qcow2 disk to a vmdk and put it a new directory
basename: base name for output vmdk file"""
vmdk = basename + '.vmdk'
log( '* Converting qcow2 to vmdk' )
run( 'qemu-img convert -f qcow2 -O vmdk %s %s' % ( cow, vmdk ) )
return vmdk | Convert a qcow2 disk to a vmdk and put it a new directory
basename: base name for output vmdk file | convert | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def generateOVF( name, osname, osid, diskname, disksize, mem=1024, cpus=1,
vmname='Mininet-VM', vminfo='A Mininet Virtual Machine' ):
"""Generate (and return) OVF file "name.ovf"
name: root name of OVF file to generate
osname: OS name for OVF (Ubuntu | Ubuntu 64-bit)
osid: OS I... | Generate (and return) OVF file "name.ovf"
name: root name of OVF file to generate
osname: OS name for OVF (Ubuntu | Ubuntu 64-bit)
osid: OS ID for OVF (93 | 94 )
diskname: name of disk file
disksize: size of virtual disk in bytes
mem: VM memory size in MB
cpus: # of virt... | generateOVF | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def qcow2size( qcow2 ):
"Return virtual disk size (in bytes) of qcow2 image"
output = check_output( [ 'qemu-img', 'info', qcow2 ] )
try:
assert 'format: qcow' in output
bytes = int( re.findall( '(\d+) bytes', output )[ 0 ] )
except:
raise Exception( 'Could not determine size of %... | Return virtual disk size (in bytes) of qcow2 image | qcow2size | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def build( flavor='raring32server', tests=None, pre='', post='', memory=1024 ):
"""Build a Mininet VM; return vmdk and vdisk size
tests: tests to run
pre: command line to run in VM before tests
post: command line to run in VM after tests
prompt: shell prompt (default '$ ')
memory:... | Build a Mininet VM; return vmdk and vdisk size
tests: tests to run
pre: command line to run in VM before tests
post: command line to run in VM after tests
prompt: shell prompt (default '$ ')
memory: memory size in MB | build | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def runTests( vm, tests=None, pre='', post='', prompt=Prompt, uninstallNtpd=False ):
"Run tests (list) in vm (pexpect object)"
# We disable ntpd and set the time so that ntpd won't be
# messing with the time during tests. Set to true for a COW
# disk and False for a non-COW disk.
if uninstallNtpd:
... | Run tests (list) in vm (pexpect object) | runTests | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def getMininetVersion( vm ):
"Run mn to find Mininet version in VM"
vm.sendline( '(cd ~/mininet; PYTHONPATH=. bin/mn --version)' )
# Eat command line echo, then read output line
vm.readline()
version = vm.readline().strip()
return version | Run mn to find Mininet version in VM | getMininetVersion | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def bootAndRun( image, prompt=Prompt, memory=1024, cpuCores=1, outputFile=None,
runFunction=None, **runArgs ):
"""Boot and test VM
tests: list of tests to run
pre: command line to run in VM before tests
post: command line to run in VM after tests
prompt: shell prompt (def... | Boot and test VM
tests: list of tests to run
pre: command line to run in VM before tests
post: command line to run in VM after tests
prompt: shell prompt (default '$ ')
memory: VM memory size in MB
cpuCores: number of CPU cores to use | bootAndRun | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def buildFlavorString():
"Return string listing valid build flavors"
return 'valid build flavors: %s' % ' '.join( sorted( isoURLs ) ) | Return string listing valid build flavors | buildFlavorString | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def testDict():
"Return dict of tests in this module"
suffix = 'Test'
trim = len( suffix )
fdict = dict( [ ( fname[ : -trim ], f ) for fname, f in
inspect.getmembers( modules[ __name__ ],
inspect.isfunction )
if fname.endswith( su... | Return dict of tests in this module | testDict | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def parseArgs():
"Parse command line arguments and run"
global LogToConsole, NoKVM, Branch, Zip, TIMEOUT, Forward, Chown
parser = argparse.ArgumentParser( description='Mininet VM build script',
epilog='' )
parser.add_argument( '-v', '--verbose', action='store_true',... | Parse command line arguments and run | parseArgs | python | mininet/mininet | util/vm/build.py | https://github.com/mininet/mininet/blob/master/util/vm/build.py | BSD-3-Clause |
def configure_output():
"""
Disable colored output and line wrapping before each test.
Some tests (e.g. test_main.py) will end up calling (and making assertions based on)
twine.cli.configure_output, which overrides this configuration. This fixture should
prevent that leaking into subsequent tests.
... |
Disable colored output and line wrapping before each test.
Some tests (e.g. test_main.py) will end up calling (and making assertions based on)
twine.cli.configure_output, which overrides this configuration. This fixture should
prevent that leaking into subsequent tests.
| configure_output | python | pypa/twine | tests/conftest.py | https://github.com/pypa/twine/blob/master/tests/conftest.py | Apache-2.0 |
def make_settings(write_config_file):
"""Return a factory function for settings.Settings with defaults."""
default_config = """
[pypi]
username:foo
password:bar
"""
def _settings(config=default_config, **settings_kwargs):
config_file = write_config_file(config)
... | Return a factory function for settings.Settings with defaults. | make_settings | python | pypa/twine | tests/conftest.py | https://github.com/pypa/twine/blob/master/tests/conftest.py | Apache-2.0 |
def _raise_home_key_error():
"""Simulate environment from https://github.com/pypa/twine/issues/889."""
try:
raise KeyError("HOME")
except KeyError:
raise KeyError("uid not found: 999") | Simulate environment from https://github.com/pypa/twine/issues/889. | _raise_home_key_error | python | pypa/twine | tests/test_auth.py | https://github.com/pypa/twine/blob/master/tests/test_auth.py | Apache-2.0 |
def test_split_inputs():
"""Split inputs into dists, signatures, and attestations."""
inputs = [
helpers.WHEEL_FIXTURE,
helpers.WHEEL_FIXTURE + ".asc",
helpers.WHEEL_FIXTURE + ".build.attestation",
helpers.WHEEL_FIXTURE + ".publish.attestation",
helpers.SDIST_FIXTURE,
... | Split inputs into dists, signatures, and attestations. | test_split_inputs | python | pypa/twine | tests/test_commands.py | https://github.com/pypa/twine/blob/master/tests/test_commands.py | Apache-2.0 |
def test_metadata_keys_consistency():
"""Check that the translation keys exist in the respective ``TypedDict``."""
raw_keys = metadata.RawMetadata.__annotations__.keys()
if version.Version(packaging.__version__) < version.Version("24.1"):
# ``packaging`` version 24.0 and earlier do not know about th... | Check that the translation keys exist in the respective ``TypedDict``. | test_metadata_keys_consistency | python | pypa/twine | tests/test_package.py | https://github.com/pypa/twine/blob/master/tests/test_package.py | Apache-2.0 |
def test_metadata_dictionary_values(gpg_signature, attestation):
"""Pass values from ``metadata.RawMetadata`` through to ``PackageMetadata``."""
meta = metadata.RawMetadata(
metadata_version=pretend.stub(),
name="whatever",
version="1.2.3",
platforms=pretend.stub(),
summa... | Pass values from ``metadata.RawMetadata`` through to ``PackageMetadata``. | test_metadata_dictionary_values | python | pypa/twine | tests/test_package.py | https://github.com/pypa/twine/blob/master/tests/test_package.py | Apache-2.0 |
def test_fips_hash_manager_md5(monkeypatch):
"""Generate hexdigest without MD5 when hashlib is using FIPS mode."""
replaced_md5 = pretend.raiser(ValueError("fipsmode"))
monkeypatch.setattr(package_file.hashlib, "md5", replaced_md5)
filename = "tests/fixtures/twine-1.5.0-py2.py3-none-any.whl"
hasher... | Generate hexdigest without MD5 when hashlib is using FIPS mode. | test_fips_hash_manager_md5 | python | pypa/twine | tests/test_package.py | https://github.com/pypa/twine/blob/master/tests/test_package.py | Apache-2.0 |
def test_fips_hash_manager_blake2(exception_class, monkeypatch):
"""Generate hexdigest without BLAKE2 when hashlib is using FIPS mode."""
replaced_blake2b = pretend.raiser(exception_class("fipsmode"))
monkeypatch.setattr(package_file.hashlib, "blake2b", replaced_blake2b)
filename = "tests/fixtures/twin... | Generate hexdigest without BLAKE2 when hashlib is using FIPS mode. | test_fips_hash_manager_blake2 | python | pypa/twine | tests/test_package.py | https://github.com/pypa/twine/blob/master/tests/test_package.py | Apache-2.0 |
def test_fips_metadata_excludes_md5_and_blake2(monkeypatch):
"""Generate a valid metadata dictionary for Nexus when FIPS is enabled.
See also: https://github.com/pypa/twine/issues/775
"""
replaced_blake2b = pretend.raiser(ValueError("fipsmode"))
replaced_md5 = pretend.raiser(ValueError("fipsmode"))... | Generate a valid metadata dictionary for Nexus when FIPS is enabled.
See also: https://github.com/pypa/twine/issues/775
| test_fips_metadata_excludes_md5_and_blake2 | python | pypa/twine | tests/test_package.py | https://github.com/pypa/twine/blob/master/tests/test_package.py | Apache-2.0 |
def test_pkginfo_returns_no_metadata(read_data, exception_message, monkeypatch):
"""Raise an exception when pkginfo can't interpret the metadata."""
monkeypatch.setattr(package_file.wheel.Wheel, "read", lambda _: read_data)
filename = "tests/fixtures/twine-1.5.0-py2.py3-none-any.whl"
with pytest.raises... | Raise an exception when pkginfo can't interpret the metadata. | test_pkginfo_returns_no_metadata | python | pypa/twine | tests/test_package.py | https://github.com/pypa/twine/blob/master/tests/test_package.py | Apache-2.0 |
def test_malformed_from_file(monkeypatch):
"""Raise an exception when malformed package file triggers EOFError."""
filename = "tests/fixtures/malformed.tar.gz"
with pytest.raises(exceptions.InvalidDistribution) as err:
package_file.PackageFile.from_filename(filename, comment=None)
assert "Inva... | Raise an exception when malformed package file triggers EOFError. | test_malformed_from_file | python | pypa/twine | tests/test_package.py | https://github.com/pypa/twine/blob/master/tests/test_package.py | Apache-2.0 |
def register_settings(make_settings):
"""Return a factory function for settings.Settings for register."""
return make_settings(
"""
[pypi]
repository: https://test.pypi.org/legacy/
username:foo
password:bar
"""
) | Return a factory function for settings.Settings for register. | register_settings | python | pypa/twine | tests/test_register.py | https://github.com/pypa/twine/blob/master/tests/test_register.py | Apache-2.0 |
def test_successful_register(register_settings):
"""Return a successful result for a valid repository url and package."""
stub_response = pretend.stub(
is_redirect=False,
status_code=200,
headers={"location": "https://test.pypi.org/legacy/"},
raise_for_status=lambda: None,
)
... | Return a successful result for a valid repository url and package. | test_successful_register | python | pypa/twine | tests/test_register.py | https://github.com/pypa/twine/blob/master/tests/test_register.py | Apache-2.0 |
def test_exception_for_redirect(register_settings):
"""Raise an exception when repository URL results in a redirect."""
repository_url = register_settings.repository_config["repository"]
redirect_url = "https://malicious.website.org/danger/"
stub_response = pretend.stub(
is_redirect=True,
... | Raise an exception when repository URL results in a redirect. | test_exception_for_redirect | python | pypa/twine | tests/test_register.py | https://github.com/pypa/twine/blob/master/tests/test_register.py | Apache-2.0 |
def test_non_existent_package(register_settings):
"""Raise an exception when package file doesn't exist."""
stub_repository = pretend.stub()
register_settings.create_repository = lambda: stub_repository
package = "/foo/bar/baz.whl"
with pytest.raises(
exceptions.PackageNotFound,
ma... | Raise an exception when package file doesn't exist. | test_non_existent_package | python | pypa/twine | tests/test_register.py | https://github.com/pypa/twine/blob/master/tests/test_register.py | Apache-2.0 |
def test_values_from_env_pypi(monkeypatch, repo):
"""Use env vars for settings when run from command line."""
def none_register(*args, **settings_kwargs):
pass
replaced_register = pretend.call_recorder(none_register)
monkeypatch.setattr(register, "register", replaced_register)
testenv = {
... | Use env vars for settings when run from command line. | test_values_from_env_pypi | python | pypa/twine | tests/test_register.py | https://github.com/pypa/twine/blob/master/tests/test_register.py | Apache-2.0 |
def test_iterables_are_flattened():
"""Flatten iterable metadata to list of tuples."""
data = {
"platform": ["UNKNOWN"],
}
tuples = repository.Repository._convert_metadata_to_list_of_tuples(data)
assert tuples == [("platform", "UNKNOWN")]
data = {
"platform": ["UNKNOWN", "ANOTH... | Flatten iterable metadata to list of tuples. | test_iterables_are_flattened | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_all_metadata_fields_are_flattened(monkeypatch):
"""Verify that package metadata fields are correctly flattened."""
if version.Version(packaging.__version__) < version.Version("24.1"):
# All metadata fields up to metadata version 2.3
metadata = open("tests/fixtures/everything.metadata23"... | Verify that package metadata fields are correctly flattened. | test_all_metadata_fields_are_flattened | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_package_is_uploaded_404s(default_repo):
"""Return False when the project API response status isn't 200."""
default_repo.session = pretend.stub(
get=lambda url, headers: response_with(status_code=404)
)
package = pretend.stub(safe_name="fake", version="2.12.0")
assert default_repo.p... | Return False when the project API response status isn't 200. | test_package_is_uploaded_404s | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_package_is_uploaded_200s_with_no_releases(default_repo):
"""Return False when the list of releases for a project is empty."""
default_repo.session = pretend.stub(
get=lambda url, headers: response_with(
status_code=200, _content=b'{"releases": {}}', _content_consumed=True
),... | Return False when the list of releases for a project is empty. | test_package_is_uploaded_200s_with_no_releases | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_package_is_uploaded_with_releases_using_cache(default_repo):
"""Return True when the package is in the releases cache."""
default_repo._releases_json_data = {"fake": {"0.1": [{"filename": "fake.whl"}]}}
package = pretend.stub(
safe_name="fake",
version="0.1",
basefilename="f... | Return True when the package is in the releases cache. | test_package_is_uploaded_with_releases_using_cache | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_package_is_uploaded_with_releases_not_using_cache(default_repo):
"""Return True when the package is in the list of releases for a project."""
default_repo.session = pretend.stub(
get=lambda url, headers: response_with(
status_code=200,
_content=b'{"releases": {"0.1": [{"... | Return True when the package is in the list of releases for a project. | test_package_is_uploaded_with_releases_not_using_cache | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_package_is_uploaded_different_filenames(default_repo):
"""Return False when the package is not in the list of releases for a project."""
default_repo.session = pretend.stub(
get=lambda url, headers: response_with(
status_code=200,
_content=b'{"releases": {"0.1": [{"filen... | Return False when the package is not in the list of releases for a project. | test_package_is_uploaded_different_filenames | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_package_is_registered(default_repo):
"""Return API response from registering a package."""
package = pretend.stub(
basefilename="fake.whl", metadata_dictionary=lambda: {"name": "fake"}
)
resp = response_with(status_code=200)
setattr(resp, "raw", pretend.stub())
setattr(resp.raw... | Return API response from registering a package. | test_package_is_registered | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_disable_progress_bar_is_forwarded_to_rich(
monkeypatch, tmpdir, disable_progress_bar, default_repo
):
"""Toggle display of upload progress bar."""
@contextmanager
def ProgressStub(*args, **kwargs):
assert "disable" in kwargs
assert kwargs["disable"] == disable_progress_bar
... | Toggle display of upload progress bar. | test_disable_progress_bar_is_forwarded_to_rich | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_upload_retry(tmpdir, default_repo, caplog):
"""Print retry messages when the upload response indicates a server error."""
default_repo.disable_progress_bar = True
default_repo.session = pretend.stub(
post=lambda url, data, allow_redirects, headers: response_with(
status_code=50... | Print retry messages when the upload response indicates a server error. | test_upload_retry | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_release_urls(package_meta, repository_url, release_urls):
"""Generate a set of PyPI release URLs for a list of packages."""
packages = [
pretend.stub(safe_name=name, version=version) for name, version in package_meta
]
repo = repository.Repository(
repository_url=repository_url... | Generate a set of PyPI release URLs for a list of packages. | test_release_urls | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_package_is_uploaded_incorrect_repo_url():
"""Return False when using an incorrect repository URL."""
repo = repository.Repository(
repository_url="https://bad.repo.com/legacy",
username="username",
password="password",
)
repo.url = "https://bad.repo.com/legacy"
ass... | Return False when using an incorrect repository URL. | test_package_is_uploaded_incorrect_repo_url | python | pypa/twine | tests/test_repository.py | https://github.com/pypa/twine/blob/master/tests/test_repository.py | Apache-2.0 |
def test_read_example(example_sdist):
"""Parse metadata from a valid sdist file."""
metadata = example_sdist.read()
assert b"Metadata-Version: 1.1" in metadata
assert b"Name: twine" in metadata
assert b"Version: 1." in metadata | Parse metadata from a valid sdist file. | test_read_example | python | pypa/twine | tests/test_sdist.py | https://github.com/pypa/twine/blob/master/tests/test_sdist.py | Apache-2.0 |
def test_read_non_existent():
"""Raise an exception when sdist file doesn't exist."""
file_name = str(pathlib.Path("/foo/bar/baz.tar.gz").resolve())
with pytest.raises(exceptions.InvalidDistribution, match="No such file"):
sdist.SDist(file_name).read() | Raise an exception when sdist file doesn't exist. | test_read_non_existent | python | pypa/twine | tests/test_sdist.py | https://github.com/pypa/twine/blob/master/tests/test_sdist.py | Apache-2.0 |
def test_formar_not_supported():
"""Raise an exception when sdist is not a .tar.gz or a .zip."""
file_name = str(pathlib.Path("/foo/bar/baz.foo").resolve())
with pytest.raises(exceptions.InvalidDistribution, match="Unsupported sdist"):
sdist.SDist(file_name).read() | Raise an exception when sdist is not a .tar.gz or a .zip. | test_formar_not_supported | python | pypa/twine | tests/test_sdist.py | https://github.com/pypa/twine/blob/master/tests/test_sdist.py | Apache-2.0 |
def test_read(archive_format, tmp_path):
"""Read PKG-INFO from a valid sdist."""
filepath = build_archive(
tmp_path,
"test-1.2.3",
archive_format,
{
"test-1.2.3/README": "README",
"test-1.2.3/PKG-INFO": """
Metadata-Version: 1.1
... | Read PKG-INFO from a valid sdist. | test_read | python | pypa/twine | tests/test_sdist.py | https://github.com/pypa/twine/blob/master/tests/test_sdist.py | Apache-2.0 |
def test_missing_pkg_info(archive_format, tmp_path):
"""Raise an exception when sdist does not contain PKG-INFO."""
filepath = build_archive(
tmp_path,
"test-1.2.3",
archive_format,
{
"test-1.2.3/README": "README",
},
)
with pytest.raises(exceptions.I... | Raise an exception when sdist does not contain PKG-INFO. | test_missing_pkg_info | python | pypa/twine | tests/test_sdist.py | https://github.com/pypa/twine/blob/master/tests/test_sdist.py | Apache-2.0 |
def test_invalid_pkg_info(archive_format, tmp_path):
"""Raise an exception when PKG-INFO does not contain ``Metadata-Version``."""
filepath = build_archive(
tmp_path,
"test-1.2.3",
archive_format,
{
"test-1.2.3/README": "README",
"test-1.2.3/PKG-INFO": """... | Raise an exception when PKG-INFO does not contain ``Metadata-Version``. | test_invalid_pkg_info | python | pypa/twine | tests/test_sdist.py | https://github.com/pypa/twine/blob/master/tests/test_sdist.py | Apache-2.0 |
def test_pkg_info_directory(archive_format, tmp_path):
"""Raise an exception when PKG-INFO is a directory."""
filepath = build_archive(
tmp_path,
"test-1.2.3",
archive_format,
{
"test-1.2.3/README": "README",
"test-1.2.3/PKG-INFO/content": """
... | Raise an exception when PKG-INFO is a directory. | test_pkg_info_directory | python | pypa/twine | tests/test_sdist.py | https://github.com/pypa/twine/blob/master/tests/test_sdist.py | Apache-2.0 |
def test_multiple_top_level(archive_format, tmp_path):
"""Raise an exception when there are too many top-level members."""
filepath = build_archive(
tmp_path,
"test-1.2.3",
archive_format,
{
"test-1.2.3/README": "README",
"test-1.2.3/PKG-INFO": """
... | Raise an exception when there are too many top-level members. | test_multiple_top_level | python | pypa/twine | tests/test_sdist.py | https://github.com/pypa/twine/blob/master/tests/test_sdist.py | Apache-2.0 |
def test_settings_takes_no_positional_arguments():
"""Raise an exception when Settings is initialized without keyword arguments."""
with pytest.raises(TypeError):
settings.Settings("a", "b", "c") | Raise an exception when Settings is initialized without keyword arguments. | test_settings_takes_no_positional_arguments | python | pypa/twine | tests/test_settings.py | https://github.com/pypa/twine/blob/master/tests/test_settings.py | Apache-2.0 |
def test_settings_transforms_repository_config_pypi(write_config_file):
"""Set repository config and defaults when .pypirc is provided.
Ignores the username setting due to PyPI being the index.
"""
config_file = write_config_file(
"""
[pypi]
repository: https://upload.pypi.org/l... | Set repository config and defaults when .pypirc is provided.
Ignores the username setting due to PyPI being the index.
| test_settings_transforms_repository_config_pypi | python | pypa/twine | tests/test_settings.py | https://github.com/pypa/twine/blob/master/tests/test_settings.py | Apache-2.0 |
def test_settings_transforms_repository_config_non_pypi(write_config_file):
"""Set repository config and defaults when .pypirc is provided."""
config_file = write_config_file(
"""
[distutils]
index-servers =
notpypi
[notpypi]
repository: https://upload.exampl... | Set repository config and defaults when .pypirc is provided. | test_settings_transforms_repository_config_non_pypi | python | pypa/twine | tests/test_settings.py | https://github.com/pypa/twine/blob/master/tests/test_settings.py | Apache-2.0 |
def test_setup_logging(verbose, log_level):
"""Set log level based on verbose field."""
settings.Settings(verbose=verbose)
logger = logging.getLogger("twine")
assert logger.level == log_level | Set log level based on verbose field. | test_setup_logging | python | pypa/twine | tests/test_settings.py | https://github.com/pypa/twine/blob/master/tests/test_settings.py | Apache-2.0 |
def test_print_config_path_if_verbose(config_file, caplog, make_settings, verbose):
"""Print the location of the .pypirc config used by the user."""
make_settings(verbose=verbose)
if verbose:
assert caplog.messages == [f"Using configuration from {config_file}"]
else:
assert caplog.messa... | Print the location of the .pypirc config used by the user. | test_print_config_path_if_verbose | python | pypa/twine | tests/test_settings.py | https://github.com/pypa/twine/blob/master/tests/test_settings.py | Apache-2.0 |
def test_password_is_required_if_no_client_cert(client_cert, entered_password):
"""Set password when client_cert is not provided."""
settings_obj = settings.Settings(username="fakeuser", client_cert=client_cert)
assert settings_obj.password == "entered pw" | Set password when client_cert is not provided. | test_password_is_required_if_no_client_cert | python | pypa/twine | tests/test_settings.py | https://github.com/pypa/twine/blob/master/tests/test_settings.py | Apache-2.0 |
def test_client_cert_and_password_both_set_if_given():
"""Set password and client_cert when both are provided."""
client_cert = "/random/path"
settings_obj = settings.Settings(
username="fakeuser", password="anything", client_cert=client_cert
)
assert settings_obj.password == "anything"
... | Set password and client_cert when both are provided. | test_client_cert_and_password_both_set_if_given | python | pypa/twine | tests/test_settings.py | https://github.com/pypa/twine/blob/master/tests/test_settings.py | Apache-2.0 |
def test_password_required_if_no_client_cert_and_non_interactive():
"""Raise exception if no password or client_cert when non interactive."""
settings_obj = settings.Settings(username="fakeuser", non_interactive=True)
with pytest.raises(exceptions.NonInteractive):
settings_obj.password | Raise exception if no password or client_cert when non interactive. | test_password_required_if_no_client_cert_and_non_interactive | python | pypa/twine | tests/test_settings.py | https://github.com/pypa/twine/blob/master/tests/test_settings.py | Apache-2.0 |
def test_no_password_prompt_if_client_cert_and_non_interactive(entered_password):
"""Don't prompt for password when client_cert is provided and non interactive."""
client_cert = "/random/path"
settings_obj = settings.Settings(
username="fakeuser", client_cert=client_cert, non_interactive=True
)
... | Don't prompt for password when client_cert is provided and non interactive. | test_no_password_prompt_if_client_cert_and_non_interactive | python | pypa/twine | tests/test_settings.py | https://github.com/pypa/twine/blob/master/tests/test_settings.py | Apache-2.0 |
def stub_repository(stub_response):
"""Allow assertions on the uploaded package."""
return pretend.stub(
upload=pretend.call_recorder(lambda package: stub_response),
close=lambda: None,
release_urls=lambda packages: set(),
) | Allow assertions on the uploaded package. | stub_repository | python | pypa/twine | tests/test_upload.py | https://github.com/pypa/twine/blob/master/tests/test_upload.py | Apache-2.0 |
def upload_settings(make_settings, stub_repository):
"""Use the stub repository when uploading."""
upload_settings = make_settings()
upload_settings.create_repository = lambda: stub_repository
return upload_settings | Use the stub repository when uploading. | upload_settings | python | pypa/twine | tests/test_upload.py | https://github.com/pypa/twine/blob/master/tests/test_upload.py | Apache-2.0 |
def test_make_package_pre_signed_dist(upload_settings, caplog):
"""Create a PackageFile and print path, size, and user-provided signature."""
filename = helpers.WHEEL_FIXTURE
expected_size = "15.4 KB"
signed_filename = helpers.WHEEL_FIXTURE + ".asc"
signatures = {os.path.basename(signed_filename): s... | Create a PackageFile and print path, size, and user-provided signature. | test_make_package_pre_signed_dist | python | pypa/twine | tests/test_upload.py | https://github.com/pypa/twine/blob/master/tests/test_upload.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.